UPDATE
This commit is contained in:
@@ -10,7 +10,7 @@ import { cn } from "@/lib/utils";
|
||||
import { formatDistanceToNow } from "date-fns";
|
||||
import axios from "axios";
|
||||
import { toast } from "sonner";
|
||||
import { ArrowLeft, Send, RefreshCw, FileText, Image as ImageIcon, Download, File } from "lucide-react";
|
||||
import { ArrowLeft, Send, RefreshCw, File, FileText, Image as ImageIcon, Download } from "lucide-react";
|
||||
import { getCookie } from "@/lib/client-utils";
|
||||
|
||||
interface Message {
|
||||
@@ -292,55 +292,49 @@ export default function ChatDetail({ chatId }: { chatId: string }) {
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<Card className="w-full h-[calc(100vh-80px)] flex flex-col">
|
||||
<CardHeader className="border-b py-2 px-4">
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Button variant="ghost" size="icon" onClick={handleBackClick}>
|
||||
<ArrowLeft className="h-5 w-5" />
|
||||
</Button>
|
||||
<span>Loading conversation...</span>
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="flex-1 flex items-center justify-center">
|
||||
<div className="flex flex-col h-screen w-full relative">
|
||||
<div className="border-b py-2 px-4 flex items-center space-x-2 bg-card z-10">
|
||||
<Button variant="ghost" size="icon" onClick={handleBackClick}>
|
||||
<ArrowLeft className="h-5 w-5" />
|
||||
</Button>
|
||||
<span className="text-lg font-semibold">Loading conversation...</span>
|
||||
</div>
|
||||
<div className="flex-1 flex items-center justify-center">
|
||||
<RefreshCw className="h-8 w-8 animate-spin text-muted-foreground" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!chat) {
|
||||
return (
|
||||
<Card className="w-full h-[calc(100vh-80px)] flex flex-col">
|
||||
<CardHeader className="border-b py-2 px-4">
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Button variant="ghost" size="icon" onClick={handleBackClick}>
|
||||
<ArrowLeft className="h-5 w-5" />
|
||||
</Button>
|
||||
<span>Chat not found</span>
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="flex-1 flex items-center justify-center">
|
||||
<div className="flex flex-col h-screen w-full relative">
|
||||
<div className="border-b py-2 px-4 flex items-center space-x-2 bg-card z-10">
|
||||
<Button variant="ghost" size="icon" onClick={handleBackClick}>
|
||||
<ArrowLeft className="h-5 w-5" />
|
||||
</Button>
|
||||
<span className="text-lg font-semibold">Chat not found</span>
|
||||
</div>
|
||||
<div className="flex-1 flex items-center justify-center">
|
||||
<div className="text-center">
|
||||
<p className="text-muted-foreground mb-4">This conversation doesn't exist or you don't have access to it.</p>
|
||||
<Button onClick={handleBackClick}>Back to Chats</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Card className="w-full h-[calc(100vh-80px)] flex flex-col">
|
||||
<CardHeader className="border-b py-2 px-4">
|
||||
<CardTitle className="flex items-center space-x-2">
|
||||
<Button variant="ghost" size="icon" onClick={handleBackClick}>
|
||||
<ArrowLeft className="h-5 w-5" />
|
||||
</Button>
|
||||
<span>Chat with Customer {chat.buyerId.slice(-4)}</span>
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<div className="flex flex-col h-screen w-full relative">
|
||||
<div className="border-b py-2 px-4 flex items-center space-x-2 bg-card z-10">
|
||||
<Button variant="ghost" size="icon" onClick={handleBackClick}>
|
||||
<ArrowLeft className="h-5 w-5" />
|
||||
</Button>
|
||||
<h3 className="text-lg font-semibold">Chat with Customer {chat.buyerId.slice(-4)}</h3>
|
||||
</div>
|
||||
|
||||
<CardContent className="flex-1 overflow-y-auto p-2 space-y-2">
|
||||
<div className="flex-1 overflow-y-auto p-2 space-y-2 pb-[58px]">
|
||||
{chat.messages.length === 0 ? (
|
||||
<div className="h-full flex items-center justify-center">
|
||||
<p className="text-muted-foreground">No messages yet. Send one to start the conversation.</p>
|
||||
@@ -447,9 +441,9 @@ export default function ChatDetail({ chatId }: { chatId: string }) {
|
||||
))
|
||||
)}
|
||||
<div ref={messagesEndRef} />
|
||||
</CardContent>
|
||||
</div>
|
||||
|
||||
<div className="p-2 border-t">
|
||||
<div className="absolute bottom-0 left-0 right-0 border-t border-border bg-background p-4">
|
||||
<form onSubmit={handleSendMessage} className="flex space-x-2">
|
||||
<Input
|
||||
value={message}
|
||||
@@ -463,6 +457,6 @@ export default function ChatDetail({ chatId }: { chatId: string }) {
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user