chatbot-template/components/chat-list.tsx

24 lines
531 B
TypeScript
Raw Normal View History

import { Separator } from '@/components/ui/separator'
2024-03-14 20:00:52 +03:00
import { UIState } from '@/lib/chat/actions'
export interface ChatList {
2024-03-14 20:00:52 +03:00
messages: UIState
}
export function ChatList({ messages }: ChatList) {
if (!messages.length) {
return null
}
return (
<div className="relative mx-auto max-w-2xl px-4">
{messages.map((message, index) => (
2024-03-14 20:00:52 +03:00
<div key={message.id}>
{message.display}
{index < messages.length - 1 && <Separator className="my-4" />}
</div>
))}
</div>
)
}