import { Head, Link, router, useForm } from '@inertiajs/react'; import { PageTitle, Panel, FormErrors, controlClass, } from '@/components/procurement'; import { Button } from '@/components/ui/button'; import { peopleStates } from '@/lib/people-hiring'; import { PeopleOperationalInsights } from '@/components/people-operational-insights'; import type { OperationalInsights } from '@/components/people-operational-insights'; const kinds: Record = { service: 'Prestador individual', staff: 'Trabalhador para o quadro', }; type WorkItem = { id: string; process_id: number; reference: string; title: string; kind: string; status: string; action: string; label: string; due_on: string | null; href: string; }; type Workdesk = { updated_at: string; counts: Record< | 'processes' | 'active' | 'contract_drafts' | 'tasks' | 'approvals' | 'overdue', number >; tasks: WorkItem[]; approvals: WorkItem[]; alerts: { id?: string; process_id: number; title: string; label: string; due_on: string; href: string; }[]; }; type Filters = { kind?: string; search?: string; status?: string; from?: string; to?: string; }; function Queue({ id, title, items, empty, }: { id: string; title: string; items: WorkItem[]; empty: string; }) { return (
{items.length ? (
{items.map((item) => ( ))}
Acção pendente Processo Percurso e estado Prazo
{item.label} {item.reference} · {item.title} {kinds[item.kind]} ·{' '} {peopleStates[item.status]} {item.due_on ?? 'Não definido'}
) : (

{empty}

)}
); } export default function PeopleIndex({ ready, kinds: allowed, canPrepare, processes, administration = [], formFields = {}, availableKinds = allowed, workdesk, insights, filters = {}, company, }: { ready: boolean; availableKinds?: string[]; workdesk?: Workdesk | null; insights?: OperationalInsights | null; filters?: Filters; company?: { name: string }; administration?: { id: number; kind: string; status: string }[]; formFields?: Record>; kinds: string[]; canPrepare: string[]; processes: null | { data: { id: number; title: string; kind: string; status: string; closes_on: string; }[]; links: { url: string | null; label: string; active: boolean }[]; }; }) { const form = useForm({ operation_key: crypto.randomUUID(), kind: filters.kind && canPrepare.includes(filters.kind) ? filters.kind : (canPrepare[0] ?? allowed[0]), title: '', purpose: '', closes_on: '', minimum_reviews: '1', criteria: [{ label: '', weight: '100' }], annex: { fields: {} as Record, requirements: [] as { description: string; classification: string; verification: string; equivalences: string; }[], }, }); const filtering = useForm({ kind: filters.kind ?? '', search: filters.search ?? '', status: filters.status ?? '', from: filters.from ?? '', to: filters.to ?? '', }); return ( <>
router.reload()} > Actualizar ) : undefined } /> {!ready ? (

O módulo ainda não foi instalado neste ambiente.

) : ( <> {company && (

Entidade activa: {company.name}

)}
{ e.preventDefault(); filtering.get('/pessoas', { preserveState: true, preserveScroll: true, }); }} >
Limpar filtros
{insights && ( )} {workdesk && ( <>
{( [ [ 'processes', 'Processos autorizados', ], [ 'contract_drafts', 'Minutas preparadas', ], ['tasks', 'As minhas tarefas'], ['approvals', 'Aprovações'], ['overdue', 'Prazos vencidos'], ] as const ).map(([key, label]) => (

{label}

{workdesk.counts[key]}
))}

Actualizado em{' '} {new Date( workdesk.updated_at, ).toLocaleString('pt-MZ')} . Contagens limitadas aos filtros e aos seus acessos. Tarefas e aprovações contam acções distintas, não pessoas nem processos duplicados.

{workdesk.alerts.length > 0 && (
    {workdesk.alerts.map((alert) => (
  • {alert.title} ·{' '} {alert.label} ·{' '} {alert.due_on}
  • ))}
)} )} {administration.length > 0 && (
{administration.map((p) => ( Processo #{p.id} · {kinds[p.kind]} ))}
)}
{processes?.data.map((p) => ( PES-{p.id} · {p.title}

{kinds[p.kind]} ·{' '} {peopleStates[p.status] ?? p.status}{' '} · candidaturas até {p.closes_on}

))} {!processes?.data.length && (

Sem processos acessíveis.

)}
{canPrepare.length > 0 && (
{ e.preventDefault(); form.transform((values) => ({ ...values, annex: { ...values.annex, fields: Object.fromEntries( Object.keys( formFields[ values.kind ] ?? {}, ).map((key) => [ key, values.annex.fields[ key ] ?? '', ]), ), }, })); form.post('/pessoas', { onSuccess: () => form.reset(), }); }} >