import { format } from 'date-fns'; import { ptBR } from 'date-fns/locale'; import { X } from 'lucide-react'; import { Dialog, DialogContent, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { UserAvatar } from '@/components/ui/user-avatar'; import { Task } from '@/types/tasks'; interface TaskViewModalProps { task: Task | null; onClose: () => void; onEdit?: (task: Task) => void; } const statusLabels = { a_fazer: 'A Fazer', em_andamento: 'Em Andamento', revisao: 'Revisão', pendente: 'Pendente', bloqueado: 'Bloqueado', concluido: 'Concluído' }; const priorityLabels = { baixa: 'Baixa', media: 'Média', alta: 'Alta', urgente: 'Urgente' }; const getPriorityBadgeColor = (priority: string) => { switch (priority) { case 'urgente': return 'bg-red-500 text-white border-red-500'; case 'alta': return 'bg-orange-500 text-white border-orange-500'; case 'media': return 'bg-yellow-500 text-white border-yellow-500'; case 'baixa': return 'bg-blue-400 text-white border-blue-400'; default: return 'bg-gray-500 text-white border-gray-500'; } }; const getStatusBadgeColor = (status: string) => { switch (status) { case 'concluido': return 'bg-green-500 text-white border-green-500'; case 'em_andamento': return 'bg-blue-500 text-white border-blue-500'; case 'revisao': return 'bg-purple-500 text-white border-purple-500'; case 'pendente': return 'bg-yellow-500 text-white border-yellow-500'; case 'bloqueado': return 'bg-red-500 text-white border-red-500'; default: return 'bg-gray-500 text-white border-gray-500'; } }; export function TaskViewModal({ task, onClose, onEdit }: TaskViewModalProps) { if (!task) return null; const priorityBadgeColor = getPriorityBadgeColor(task.priority || 'media'); const statusBadgeColor = getStatusBadgeColor(task.status || 'a_fazer'); return (
Detalhes da Tarefa - {task.task_ref}
OF: {task.of_number} {task.revision && task.revision > 1 && ( Revisão {task.revision} )}
{/* Status and Priority */}
{statusLabels[task.status || 'a_fazer']}
{priorityLabels[task.priority || 'media']}
{/* Title */}

{task.title}

{/* Description */} {task.description && (

{task.description}

)} {/* Category */} {task.category && (

{task.category}

)} {/* Due Date */} {task.due_date && (

{format(new Date(task.due_date), "dd 'de' MMMM 'de' yyyy", { locale: ptBR })}

)} {/* Assigned Users */} {task.assigned_profiles && task.assigned_profiles.length > 0 && (
{task.assigned_profiles.map((profile) => (
{profile.full_name || profile.email}
))}
)} {/* Creator */} {task.creator_profile && (
{task.creator_profile.full_name || task.creator_profile.email}
)} {/* Timestamps */}

{format(new Date(task.created_at), "dd/MM/yyyy 'às' HH:mm", { locale: ptBR })}

{task.updated_at && task.updated_at !== task.created_at && (

{format(new Date(task.updated_at), "dd/MM/yyyy 'às' HH:mm", { locale: ptBR })}

)} {task.completed_at && (

{format(new Date(task.completed_at), "dd/MM/yyyy 'às' HH:mm", { locale: ptBR })}

)}
{/* Actions */}
{onEdit && ( )}
); }