115 lines
4.0 KiB
TypeScript
115 lines
4.0 KiB
TypeScript
import { useForm } from '@inertiajs/react';
|
|
import { Panel, FormErrors, controlClass } from '@/components/procurement';
|
|
import { Button } from '@/components/ui/button';
|
|
|
|
export function PeopleContractFormalization({
|
|
id,
|
|
version,
|
|
}: {
|
|
id: number;
|
|
version: number;
|
|
}) {
|
|
const form = useForm<{
|
|
version: number;
|
|
operation_key: string;
|
|
reference: string;
|
|
signed_on: string;
|
|
reason: string;
|
|
no_conflict: boolean;
|
|
signed_document: File | null;
|
|
}>({
|
|
version,
|
|
operation_key: crypto.randomUUID(),
|
|
reference: '',
|
|
signed_on: '',
|
|
reason: '',
|
|
no_conflict: false,
|
|
signed_document: null,
|
|
});
|
|
return (
|
|
<Panel title="Confirmar contrato assinado — Direcção">
|
|
<form
|
|
className="space-y-4"
|
|
onSubmit={(event) => {
|
|
event.preventDefault();
|
|
if (!form.processing)
|
|
form.post(`/pessoas/${id}/formalizar`, {
|
|
forceFormData: true,
|
|
preserveState: 'errors',
|
|
preserveScroll: true,
|
|
});
|
|
}}
|
|
>
|
|
<FormErrors errors={form.errors} />
|
|
<label className="block">
|
|
Referência do contrato assinado
|
|
<input
|
|
required
|
|
maxLength={200}
|
|
className={controlClass}
|
|
value={form.data.reference}
|
|
onChange={(event) =>
|
|
form.setData('reference', event.target.value)
|
|
}
|
|
/>
|
|
</label>
|
|
<label className="block">
|
|
Data da assinatura
|
|
<input
|
|
required
|
|
type="date"
|
|
className={controlClass}
|
|
value={form.data.signed_on}
|
|
onChange={(event) =>
|
|
form.setData('signed_on', event.target.value)
|
|
}
|
|
/>
|
|
</label>
|
|
<label className="block">
|
|
Contrato assinado (PDF, até 10 MB)
|
|
<input
|
|
required
|
|
type="file"
|
|
accept="application/pdf"
|
|
className={controlClass}
|
|
onChange={(event) =>
|
|
form.setData(
|
|
'signed_document',
|
|
event.target.files?.[0] ?? null,
|
|
)
|
|
}
|
|
/>
|
|
</label>
|
|
<label className="block">
|
|
Fundamento da confirmação
|
|
<textarea
|
|
required
|
|
minLength={10}
|
|
maxLength={4000}
|
|
className={controlClass}
|
|
value={form.data.reason}
|
|
onChange={(event) =>
|
|
form.setData('reason', event.target.value)
|
|
}
|
|
/>
|
|
</label>
|
|
<label className="flex items-start gap-2">
|
|
<input
|
|
required
|
|
type="checkbox"
|
|
checked={form.data.no_conflict}
|
|
onChange={(event) =>
|
|
form.setData('no_conflict', event.target.checked)
|
|
}
|
|
/>
|
|
Confirmo a assinatura e a ausência de conflito de interesses
|
|
nesta intervenção.
|
|
</label>
|
|
<Button disabled={form.processing} type="submit">
|
|
Confirmar formalização
|
|
</Button>
|
|
</form>
|
|
</Panel>
|
|
);
|
|
}
|