2023-05-19 12:33:56 -04:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import { type Message } from "@prisma/client";
|
|
|
|
|
|
|
|
|
|
import { ChatMessage } from "./chat-message";
|
2023-05-19 16:06:02 -04:00
|
|
|
import { NextChatLogo } from "@/components/ui/nextchat-logo";
|
|
|
|
|
import { Plus } from "lucide-react";
|
2023-05-23 16:49:07 +02:00
|
|
|
import { EmptyScreen } from "./empty";
|
2023-05-19 12:33:56 -04:00
|
|
|
|
|
|
|
|
export interface ChatList {
|
|
|
|
|
messages: Message[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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">
|
|
|
|
|
{messages.map((message) => (
|
|
|
|
|
<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>
|
|
|
|
|
);
|
|
|
|
|
}
|