import { useState } from 'react'; import { useForm } from '@inertiajs/react'; import { FormErrors, controlClass } from '@/components/procurement'; import { Button } from '@/components/ui/button'; type Choice = { value: string; label: string }; type Props = { route: string; record: { record_key: string; version: number }; choices: Choice[]; today?: string; data?: Record; }; function Confirm({ props, choice }: { props: Props; choice: Choice }) { const form = useForm({ operation_key: crypto.randomUUID(), record_key: props.record.record_key, version: props.record.version, action: choice.value, reason: '', data: { ...props.data, ...(choice.value === 'execute' ? { event_on: props.today ?? '', evidence: '' } : {}), }, }); return (
{ e.preventDefault(); form.post(props.route); }} >