import { Head, Link, useForm } from '@inertiajs/react'; import { FormErrors, PageTitle, Panel } from '@/components/procurement'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; type Participant = { name: string; capacity: string; group: 'jury' | 'participant'; }; type Proposal = { id: number; reference: string; currency: string; supplier: { name: string } | null; subtotal_minor: number; tax_minor: number; total_minor: number; }; type Opening = { id: number; revision: number; opened_at: string; timezone: string; location: string; reference: string; reason: string; notes: string | null; participants: Participant[]; annexes: string[]; created_at: string; snapshot: { author: { name: string }; proposals: Proposal[] }; }; type Props = { requisition: { id: number; number: string; justification: string }; proposals: Proposal[]; basisHash: string; latestId: number; sourceChanged: boolean; canRecord: boolean; openings: { data: Opening[]; prev_page_url: string | null; next_page_url: string | null; }; }; const selectClass = 'h-10 w-full rounded-md border bg-background px-3 text-sm'; const amount = (minor: number, currency: string) => `${(minor / 100).toLocaleString('pt-PT', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} ${currency}`; const sessionDate = (utc: string, timezone: string) => new Date(`${utc.replace(' ', 'T')}Z`).toLocaleString('pt-PT', { timeZone: timezone, dateStyle: 'short', timeStyle: 'short', }); function OpeningForm({ requisition, proposals, basisHash, latestId, }: Pick) { const form = useForm({ previous_id: latestId, basis_hash: basisHash, opened_at: '', timezone: 'Africa/Johannesburg', submission_deadline: '', reference: '', location: '', reason: '', notes: '', quotation_ids: [] as number[], participants: [ { name: '', capacity: '', group: 'participant' }, ] as Participant[], annexes_text: '', confirmed: false, }); const participant = (index: number, change: Partial) => form.setData( 'participants', form.data.participants.map((entry, position) => position === index ? { ...entry, ...change } : entry, ), ); return (
{ event.preventDefault(); form.transform(({ annexes_text, ...data }) => ({ ...data, annexes: annexes_text .split('\n') .map((line) => line.trim()) .filter(Boolean), })); form.post(`/requisicoes/${requisition.id}/abertura`, { preserveScroll: true, }); }} className="space-y-5" > {form.data.basis_hash !== basisHash && (

As propostas foram actualizadas. Confira os valores abaixo; os textos introduzidos foram mantidos.

)}
Propostas incluídas na sessão

Os valores são copiados da aplicação. Seleccione e confira as propostas incluídas.

{proposals.map((proposal) => ( ))}
Intervenientes declarados {form.data.participants.map((entry, index) => (
{form.data.participants.length > 1 && ( )}
))}