UPDATE
This commit is contained in:
@@ -11,9 +11,7 @@ export const metadata: Metadata = {
|
|||||||
export default function ChatDetailPage({ params }: { params: { id: string } }) {
|
export default function ChatDetailPage({ params }: { params: { id: string } }) {
|
||||||
return (
|
return (
|
||||||
<Dashboard>
|
<Dashboard>
|
||||||
<div className="h-full w-full">
|
|
||||||
<ChatDetail chatId={params.id} />
|
<ChatDetail chatId={params.id} />
|
||||||
</div>
|
|
||||||
</Dashboard>
|
</Dashboard>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ import { cn } from "@/lib/utils";
|
|||||||
import { formatDistanceToNow } from "date-fns";
|
import { formatDistanceToNow } from "date-fns";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { toast } from "sonner";
|
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";
|
import { getCookie } from "@/lib/client-utils";
|
||||||
|
|
||||||
interface Message {
|
interface Message {
|
||||||
@@ -292,55 +292,49 @@ export default function ChatDetail({ chatId }: { chatId: string }) {
|
|||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
<Card className="w-full h-[calc(100vh-80px)] flex flex-col">
|
<div className="flex flex-col h-screen w-full relative">
|
||||||
<CardHeader className="border-b py-2 px-4">
|
<div className="border-b py-2 px-4 flex items-center space-x-2 bg-card z-10">
|
||||||
<CardTitle className="flex items-center space-x-2">
|
|
||||||
<Button variant="ghost" size="icon" onClick={handleBackClick}>
|
<Button variant="ghost" size="icon" onClick={handleBackClick}>
|
||||||
<ArrowLeft className="h-5 w-5" />
|
<ArrowLeft className="h-5 w-5" />
|
||||||
</Button>
|
</Button>
|
||||||
<span>Loading conversation...</span>
|
<span className="text-lg font-semibold">Loading conversation...</span>
|
||||||
</CardTitle>
|
</div>
|
||||||
</CardHeader>
|
<div className="flex-1 flex items-center justify-center">
|
||||||
<CardContent className="flex-1 flex items-center justify-center">
|
|
||||||
<RefreshCw className="h-8 w-8 animate-spin text-muted-foreground" />
|
<RefreshCw className="h-8 w-8 animate-spin text-muted-foreground" />
|
||||||
</CardContent>
|
</div>
|
||||||
</Card>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
return (
|
return (
|
||||||
<Card className="w-full h-[calc(100vh-80px)] flex flex-col">
|
<div className="flex flex-col h-screen w-full relative">
|
||||||
<CardHeader className="border-b py-2 px-4">
|
<div className="border-b py-2 px-4 flex items-center space-x-2 bg-card z-10">
|
||||||
<CardTitle className="flex items-center space-x-2">
|
|
||||||
<Button variant="ghost" size="icon" onClick={handleBackClick}>
|
<Button variant="ghost" size="icon" onClick={handleBackClick}>
|
||||||
<ArrowLeft className="h-5 w-5" />
|
<ArrowLeft className="h-5 w-5" />
|
||||||
</Button>
|
</Button>
|
||||||
<span>Chat not found</span>
|
<span className="text-lg font-semibold">Chat not found</span>
|
||||||
</CardTitle>
|
</div>
|
||||||
</CardHeader>
|
<div className="flex-1 flex items-center justify-center">
|
||||||
<CardContent className="flex-1 flex items-center justify-center">
|
|
||||||
<div className="text-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>
|
<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>
|
<Button onClick={handleBackClick}>Back to Chats</Button>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</div>
|
||||||
</Card>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="w-full h-[calc(100vh-80px)] flex flex-col">
|
<div className="flex flex-col h-screen w-full relative">
|
||||||
<CardHeader className="border-b py-2 px-4">
|
<div className="border-b py-2 px-4 flex items-center space-x-2 bg-card z-10">
|
||||||
<CardTitle className="flex items-center space-x-2">
|
|
||||||
<Button variant="ghost" size="icon" onClick={handleBackClick}>
|
<Button variant="ghost" size="icon" onClick={handleBackClick}>
|
||||||
<ArrowLeft className="h-5 w-5" />
|
<ArrowLeft className="h-5 w-5" />
|
||||||
</Button>
|
</Button>
|
||||||
<span>Chat with Customer {chat.buyerId.slice(-4)}</span>
|
<h3 className="text-lg font-semibold">Chat with Customer {chat.buyerId.slice(-4)}</h3>
|
||||||
</CardTitle>
|
</div>
|
||||||
</CardHeader>
|
|
||||||
|
|
||||||
<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 ? (
|
{chat.messages.length === 0 ? (
|
||||||
<div className="h-full flex items-center justify-center">
|
<div className="h-full flex items-center justify-center">
|
||||||
<p className="text-muted-foreground">No messages yet. Send one to start the conversation.</p>
|
<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} />
|
<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">
|
<form onSubmit={handleSendMessage} className="flex space-x-2">
|
||||||
<Input
|
<Input
|
||||||
value={message}
|
value={message}
|
||||||
@@ -463,6 +457,6 @@ export default function ChatDetail({ chatId }: { chatId: string }) {
|
|||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -27,12 +27,14 @@ export default function Layout({ children }: LayoutProps) {
|
|||||||
<div className={`flex h-screen ${theme === "dark" ? "dark" : ""}`}>
|
<div className={`flex h-screen ${theme === "dark" ? "dark" : ""}`}>
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
<div className="w-full flex flex-1 flex-col">
|
<div className="w-full flex flex-1 flex-col">
|
||||||
|
{!isChatDetailPage && (
|
||||||
<header className="h-16 border-b border-border flex items-center justify-end px-6">
|
<header className="h-16 border-b border-border flex items-center justify-end px-6">
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<UnifiedNotifications />
|
<UnifiedNotifications />
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main className={`flex-1 overflow-auto ${isChatDetailPage ? 'p-0' : 'p-6'} dark:bg-[#0F0F12]`}>
|
)}
|
||||||
|
<main className={`flex-1 ${isChatDetailPage ? 'p-0 overflow-hidden' : 'p-6 overflow-auto'} dark:bg-[#0F0F12] relative`}>
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user