'use client' import { useRouter } from 'next/navigation' import { NotebookResponse } from '@/lib/types/api' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { MoreHorizontal, Archive, ArchiveRestore, Trash2, FileText, StickyNote } from 'lucide-react' import { formatDistanceToNow } from 'date-fns' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu' import { useUpdateNotebook, useDeleteNotebook } from '@/lib/hooks/use-notebooks' import { ConfirmDialog } from '@/components/common/ConfirmDialog' import { useState } from 'react' interface NotebookCardProps { notebook: NotebookResponse } export function NotebookCard({ notebook }: NotebookCardProps) { const [showDeleteDialog, setShowDeleteDialog] = useState(false) const router = useRouter() const updateNotebook = useUpdateNotebook() const deleteNotebook = useDeleteNotebook() const handleArchiveToggle = (e: React.MouseEvent) => { e.stopPropagation() updateNotebook.mutate({ id: notebook.id, data: { archived: !notebook.archived } }) } const handleDelete = () => { deleteNotebook.mutate(notebook.id) setShowDeleteDialog(false) } const handleCardClick = () => { router.push(`/notebooks/${encodeURIComponent(notebook.id)}`) } return ( <> {notebook.name} {notebook.archived && ( Archived )} e.stopPropagation()} > e.stopPropagation()}> {notebook.archived ? ( <> Unarchive > ) : ( <> Archive > )} { e.stopPropagation() setShowDeleteDialog(true) }} className="text-red-600" > Delete {notebook.description || 'No description'} Updated {formatDistanceToNow(new Date(notebook.updated), { addSuffix: true })} {/* Item counts footer */} {notebook.source_count} {notebook.note_count} > ) }