import { Link, useForm } from '@inertiajs/react'; import { useRef } from 'react'; import { Panel, controlClass } from '@/components/procurement'; import { Button } from '@/components/ui/button'; type Payload = { title: string; received_on: string | null; source_reference: string; statement: string; }; type Decision = { outcome: string; reason: string; follow_up: string; response_reference: string; }; type Record = { id: number; version: number; status: string; payload: Payload; decision: Decision | null; created_by: number; reviewed_by: number | null; reviewed_at: string | null; review_reason: string | null; canEdit: boolean; canReview: boolean; }; type History = { id: number; user_id: number; action: string; created_at: string; after: Record; }; export type ResponseData = { ready: boolean; canCreate: boolean; records: Record[]; history: { data: History[]; total: number; prev_page_url: string | null; next_page_url: string | null; } | null; }; const states: { [key: string]: string } = { draft: 'Em preparação', review: 'Em análise', returned: 'Devolvido para completar', decided: 'Conclusão registada', }; const outcomes: { [key: string]: string } = { accepted: 'Argumentos acolhidos', partially_accepted: 'Argumentos parcialmente acolhidos', not_accepted: 'Argumentos não acolhidos', }; const actions: { [key: string]: string } = { create: 'Registo', save: 'Alteração', submit: 'Submissão para análise', return: 'Devolução', decide: 'Conclusão independente', }; const empty: Payload = { title: '', received_on: '', source_reference: '', statement: '', }; function Errors({ errors }: { errors: { [key: string]: string } }) { return Object.keys(errors).length ? (
{Object.entries(errors).map(([key, message]) => (

{message}

))}
) : null; } function Fields({ payload, change, }: { payload: Payload; change: (key: keyof Payload, value: string) => void; }) { return (