chatbot-template/app/chat-list.tsx

47 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-06-02 15:33:48 -04:00
'use client'
2023-05-19 12:33:56 -04:00
2023-06-02 15:33:48 -04:00
import { type Message } from 'ai-connector'
2023-05-19 12:33:56 -04:00
2023-06-02 15:33:48 -04:00
import { ChatMessage } from './chat-message'
import { NextChatLogo } from '@/components/ui/nextchat-logo'
import { Plus } from 'lucide-react'
import { EmptyScreen } from './empty'
2023-05-19 12:33:56 -04:00
export interface ChatList {
2023-06-02 15:33:48 -04:00
messages: Message[]
2023-05-19 12:33:56 -04:00
}
export function ChatList({ messages }: ChatList) {
return (
<div className="relative h-full dark:bg-zinc-900">
2023-05-22 13:24:09 +02:00
<div className="sticky top-0 border-b w-full bg-black md:hidden text-white font-semibold">
2023-05-19 16:06:02 -04:00
<div className="px-4 py-2 flex items-center justify-between">
2023-05-23 17:17:27 +02:00
<div className="flex flex-row gap-2 whitespace-nowrap items-center">
2023-05-19 16:06:02 -04:00
<NextChatLogo className="h-6 w-6" />
<span className="select-none">Next.js Chatbot</span>
</div>
<div>
<button className="text-white p-2 rounded hover:bg-zinc-800 transition duration-100">
<Plus className="h-4 w-4" />
</button>
</div>
</div>
</div>
2023-05-19 12:33:56 -04:00
<div className="h-full w-full overflow-auto">
{messages.length > 0 ? (
<div className="group w-full text-zinc-900 dark:text-white divide-y dark:divide-zinc-800">
2023-06-02 15:33:48 -04:00
{messages.map(message => (
2023-05-19 12:33:56 -04:00
<ChatMessage
key={message.id || message.content}
message={message}
/>
))}
</div>
2023-05-23 16:49:07 +02:00
) : (
<EmptyScreen />
)}
2023-05-19 12:33:56 -04:00
</div>
</div>
2023-06-02 15:33:48 -04:00
)
2023-05-19 12:33:56 -04:00
}