import { Link, useForm } from '@inertiajs/react'; import { useRef } from 'react'; import { Panel, controlClass } from '@/components/procurement'; import { Button } from '@/components/ui/button'; type Person = { id: number; name: string }; type Plan = { title: string; description: string; responsible_id: string; due_on: string; }; type Measure = { id: number; title: string; description: string; responsible_id: number; due_on: string; status: string; version: number; result: string | null; evidence: string | null; reviewed_by: number | null; review_reason: string | null; reviewed_at: string | null; canPlan: boolean; canExecute: boolean; canReview: boolean; }; type Event = { id: number; action: string; user_id: number; created_at: string; after: Measure & { change_reason?: string }; }; export type ImprovementData = { ready: boolean; canCreate: boolean; today: string; records: Measure[]; assignees: Person[]; history: { data: Event[]; total: number; prev_page_url: string | null; next_page_url: string | null; } | null; }; const states: Record = { open: 'Em execução', review: 'A aguardar conferência', returned: 'Devolvida para correcção', closed: 'Encerrada', }; const events: Record = { create: 'Criação', plan: 'Alteração do plano', progress: 'Execução registada', submit: 'Pedido de encerramento', return: 'Devolução', close: 'Encerramento independente', }; const freshPlan: Plan = { title: '', description: '', responsible_id: '', due_on: '', }; function Errors({ errors }: { errors: Record }) { return Object.keys(errors).length ? (
{Object.entries(errors).map(([key, text]) => (

{text}

))}
) : null; } function PlanFields({ data, change, people, }: { data: Plan; change: (key: keyof Plan, value: string) => void; people: Person[]; }) { return (