import { Head } from '@inertiajs/react'; import { useState } from 'react'; import { profileJson } from '@/lib/profile-json'; import { createOperationKey } from '@/lib/operation-key'; export default function OfferReport({ offerId }: { offerId: number }) { const [key] = useState(createOperationKey); const [reason, setReason] = useState(''); const [confirm, setConfirm] = useState(false); const [busy, setBusy] = useState(false); const [sent, setSent] = useState(false); const [message, setMessage] = useState(''); async function submit() { setBusy(true); try { const result = await profileJson( `/minhas-oportunidades/ofertas/${offerId}/denuncias`, { client_key: key, reason, confirm }, ); setSent(true); setMessage(`Denúncia registada. Referência: ${result.id}.`); } catch (error) { setMessage( error instanceof Error ? error.message : 'Não foi possível registar a denúncia.', ); } finally { setBusy(false); } } return (

Denunciar oferta

Explique os factos que justificam a denúncia. A equipa responsável irá analisá-la em privado.

{ event.preventDefault(); void submit(); }} className="space-y-4" >