'use client' import { useState } from 'react' import { NotebookResponse } from '@/lib/types/api' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { Archive, ArchiveRestore, Trash2 } from 'lucide-react' import { useUpdateNotebook } from '@/lib/hooks/use-notebooks' import { NotebookDeleteDialog } from './NotebookDeleteDialog' import { formatDistanceToNow } from 'date-fns' import { getDateLocale } from '@/lib/utils/date-locale' import { InlineEdit } from '@/components/common/InlineEdit' import { useTranslation } from '@/lib/hooks/use-translation' interface NotebookHeaderProps { notebook: NotebookResponse } export function NotebookHeader({ notebook }: NotebookHeaderProps) { const { t, language } = useTranslation() const dfLocale = getDateLocale(language) const [showDeleteDialog, setShowDeleteDialog] = useState(false) const updateNotebook = useUpdateNotebook() const handleUpdateName = async (name: string) => { if (!name || name === notebook.name) return await updateNotebook.mutateAsync({ id: notebook.id, data: { name } }) } const handleUpdateDescription = async (description: string) => { if (description === notebook.description) return await updateNotebook.mutateAsync({ id: notebook.id, data: { description: description || undefined } }) } const handleArchiveToggle = () => { updateNotebook.mutate({ id: notebook.id, data: { archived: !notebook.archived } }) } return ( <>