import { useRef } from 'react' import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DialogDescription, } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' import { toast } from 'sonner' import { useTranslation } from '@/i18n/react-i18next-compat' interface DeleteProjectDialogProps { open: boolean onOpenChange: (open: boolean) => void onConfirm: () => void projectName?: string } export function DeleteProjectDialog({ open, onOpenChange, onConfirm, projectName, }: DeleteProjectDialogProps) { const { t } = useTranslation() const deleteButtonRef = useRef(null) const handleConfirm = () => { try { onConfirm() toast.success( projectName ? t('projects.deleteProjectDialog.successWithName', { projectName }) : t('projects.deleteProjectDialog.successWithoutName') ) onOpenChange(false) } catch (error) { toast.error(t('projects.deleteProjectDialog.error')) console.error('Delete project error:', error) } } const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { handleConfirm() } } return ( { e.preventDefault() deleteButtonRef.current?.focus() }} > {t('projects.deleteProjectDialog.title')} {t('projects.deleteProjectDialog.description')} ) }