'use client' import { useState } from 'react' import { Trash2 } from 'lucide-react' import { Button } from '@/components/ui/button' import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog' import { useLanguage } from '@/lib/i18n' import { emptyTrash } from '@/app/actions/notes' import { useRouter } from 'next/navigation' import { toast } from 'sonner' interface TrashHeaderProps { noteCount?: number } export function TrashHeader({ noteCount = 0 }: TrashHeaderProps) { const { t } = useLanguage() const router = useRouter() const [showEmptyDialog, setShowEmptyDialog] = useState(false) const [isEmptying, setIsEmptying] = useState(false) const handleEmptyTrash = async () => { setIsEmptying(true) try { await emptyTrash() toast.success(t('trash.emptyTrashSuccess')) router.refresh() } catch (error) { console.error('Error emptying trash:', error) } finally { setIsEmptying(false) setShowEmptyDialog(false) } } return (