import { Link } from '@inertiajs/react'; import { states as interestStates } from '@/pages/management/shared'; import { taskStates } from '@/pages/crm/types'; type WorkItem = { id: string; title: string; reference: string | null; status: string; due_at: string | null; overdue: boolean; href: string; }; type WorkGroup = { total: number; overdue: number; items: WorkItem[]; page: number; last_page: number; previous: string | null; next: string | null; }; export type DashboardQueue = { as_of: string; desk_states: Record; groups: Partial>; }; const groups = { interests: 'Manifestações atribuídas a mim', desk: 'Pedidos do Balcão atribuídos a mim', crm_tasks: 'Tarefas do CRM atribuídas a mim', } as const; const date = (value: string) => new Intl.DateTimeFormat('pt-MZ', { dateStyle: 'medium', timeStyle: 'short', timeZone: 'Africa/Maputo', }).format(new Date(value)); export default function DashboardWorkQueue({ queue, }: { queue: DashboardQueue | null | undefined; }) { if (!queue) return null; return (

O meu acompanhamento

Pedidos e tarefas atribuídos a si, por prazo. Actualizado em{' '} .

{Object.entries(groups).map(([kind, title]) => { const group = queue.groups[kind as keyof typeof groups]; if (!group) return null; const states = kind === 'interests' ? interestStates : kind === 'desk' ? queue.desk_states : taskStates; return (

{title}

{group.total} por acompanhar · {group.overdue}{' '} com prazo ultrapassado

{group.items.length ? (
    {group.items.map((item) => (
  • {item.title} {item.reference && (

    {item.reference}

    )}

    {states[item.status] ?? item.status}

    {item.due_at ? ( <> {item.overdue && ( {' '} · Prazo ultrapassado )} ) : ( 'Sem prazo definido' )}

  • ))}
) : (

Não tem registos activos atribuídos neste acompanhamento.

)} {group.last_page > 1 && ( )}
); })}
); }