import { memo, useState } from 'react' import { useTranslation } from 'react-i18next' import type { Job } from '@/types/job' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from '@/components/ui/alert-dialog' import { Trash2, AlertCircle, Loader2, Clock, Eye } from 'lucide-react' import { getRelativeTime, cn } from '@/lib/utils' import { JobDetailDialog } from '@/components/JobDetailDialog' interface HistoryItemProps { job: Job onDelete: (id: number) => void } const jobTypeBadgeVariant = { custom_voice: 'default' as const, voice_design: 'secondary' as const, voice_clone: 'outline' as const, } const HistoryItem = memo(({ job, onDelete }: HistoryItemProps) => { const { t } = useTranslation('job') const { t: tCommon } = useTranslation('common') const [detailDialogOpen, setDetailDialogOpen] = useState(false) const jobTypeLabel = { custom_voice: t('typeCustomVoice'), voice_design: t('typeVoiceDesign'), voice_clone: t('typeVoiceClone'), } const getLanguageDisplay = (lang: string | undefined) => { if (!lang || lang === 'Auto') return t('autoDetect') return lang } const handleCardClick = (e: React.MouseEvent) => { if ((e.target as HTMLElement).closest('button')) return setDetailDialogOpen(true) } return (