diff --git a/app/dashboard/chats/[id]/page.tsx b/app/dashboard/chats/[id]/page.tsx index 1de7692..81931ee 100644 --- a/app/dashboard/chats/[id]/page.tsx +++ b/app/dashboard/chats/[id]/page.tsx @@ -11,10 +11,8 @@ export const metadata: Metadata = { export default function ChatDetailPage({ params }: { params: { id: string } }) { return ( -
-
- -
+
+
); diff --git a/components/dashboard/ChatDetail.tsx b/components/dashboard/ChatDetail.tsx index 34d3452..b326bfa 100644 --- a/components/dashboard/ChatDetail.tsx +++ b/components/dashboard/ChatDetail.tsx @@ -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 } from "lucide-react"; +import { ArrowLeft, Send, RefreshCw, FileText, Image as ImageIcon, Download, File } from "lucide-react"; import { getCookie } from "@/lib/client-utils"; interface Message { @@ -34,6 +34,50 @@ interface Chat { orderId?: string; } +// Helper function to extract filename from URL +const getFileNameFromUrl = (url: string): string => { + // Try to extract filename from the URL path + const pathParts = url.split('/'); + const lastPart = pathParts[pathParts.length - 1]; + + // Remove query parameters if any + const fileNameParts = lastPart.split('?'); + let fileName = fileNameParts[0]; + + // If filename is too long or not found, create a generic name + if (!fileName || fileName.length > 30) { + return 'attachment'; + } + + // URL decode the filename (handle spaces and special characters) + try { + fileName = decodeURIComponent(fileName); + } catch (e) { + // If decoding fails, use the original + } + + return fileName; +}; + +// Helper function to get file icon based on extension or URL pattern +const getFileIcon = (url: string): React.ReactNode => { + const fileName = url.toLowerCase(); + + // Image files + if (/\.(jpg|jpeg|png|gif|webp|svg|bmp|tiff)($|\?)/i.test(fileName) || + url.includes('/photos/') || url.includes('/photo/')) { + return ; + } + + // Document files + if (/\.(pdf|doc|docx|xls|xlsx|ppt|pptx|txt|rtf|csv)($|\?)/i.test(fileName)) { + return ; + } + + // Default file icon + return ; +}; + export default function ChatDetail({ chatId }: { chatId: string }) { const router = useRouter(); const [chat, setChat] = useState(null); @@ -248,8 +292,8 @@ export default function ChatDetail({ chatId }: { chatId: string }) { if (loading) { return ( - - + +
)) @@ -339,7 +449,7 @@ export default function ChatDetail({ chatId }: { chatId: string }) {
-
+
setMounted(true), []) @@ -27,7 +32,9 @@ export default function Layout({ children }: LayoutProps) {
-
{children}
+
+ {children} +
) diff --git a/public/placeholder-image.svg b/public/placeholder-image.svg new file mode 100644 index 0000000..1e98f77 --- /dev/null +++ b/public/placeholder-image.svg @@ -0,0 +1 @@ +Image unavailable