novas funcionalidades dos formulario
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-02 11:13:37 +02:00
parent a6afb4e97a
commit 4f35313d06
104 changed files with 7653 additions and 178 deletions
+61 -3
View File
@@ -14,6 +14,11 @@ type Interest = {
investment_range: string | null;
message: string;
status: string;
existing_business_id: string | null;
modality: string | null;
assigned_to: number | null;
next_action: string | null;
next_action_due_at: string | null;
consented_at: string | null;
reviewed_at: string | null;
reviewed_by: number | null;
@@ -34,8 +39,13 @@ function dateTime(value: string | null) {
timeZone: "Africa/Maputo",
}).format(new Date(value));
}
export default function InterestDetail({ interest }: { interest: Interest }) {
const form = useForm({ status: interest.status });
type Transition = { from_status: string | null; to_status: string; actor_id: number | null; note: string | null; created_at: string };
type Assignee = { id: number; name: string };
type Consent = { purpose: string; policy_version: string | null; status: string; granted_at: string | null; withdrawn_at: string | null };
export default function InterestDetail({ interest, history = [], assignees = [], consents = [] }: { interest: Interest; history?: Transition[]; assignees?: Assignee[]; consents?: Consent[] }) {
const form = useForm({ status: interest.status, note: "", next_action: interest.next_action ?? "", next_action_due_at: interest.next_action_due_at?.slice(0, 10) ?? "", assigned_to: interest.assigned_to?.toString() ?? "" });
const consentForm = useForm({ reason: "" });
const rows: [string, string | number | null][] = [
["Nome", interest.full_name],
["Email", interest.email],
@@ -44,6 +54,8 @@ export default function InterestDetail({ interest }: { interest: Interest }) {
["País", interest.country],
["Sector", interest.sector_interest],
["Oportunidade", interest.opportunity_reference],
["Negócio publicado", interest.existing_business_id],
["Modalidade", interest.modality],
["Faixa de investimento", interest.investment_range],
["Recebido em (Maputo)", dateTime(interest.created_at)],
["Consentimento em (Maputo)", dateTime(interest.consented_at)],
@@ -90,6 +102,27 @@ export default function InterestDetail({ interest }: { interest: Interest }) {
<h2 className="font-semibold">Mensagem</h2>
<p className="mt-2 break-words whitespace-pre-wrap">{interest.message}</p>
</section>
<section className="space-y-3">
<h2 className="font-semibold">Consentimentos e versões</h2>
{consents.map((consent, index) => (
<article key={`${consent.purpose}-${index}`} className="rounded border p-3">
<p>{consent.purpose}: {consent.status}</p>
<p className="text-sm">Política {consent.policy_version ?? "—"} · concedido {dateTime(consent.granted_at)}</p>
{consent.withdrawn_at && <p className="text-sm">Revogado {dateTime(consent.withdrawn_at)}</p>}
</article>
))}
{consents.some((consent) => consent.purpose === "share_contact_with_proponent" && consent.status === "granted") && (
<form className="max-w-sm space-y-3" onSubmit={(event) => {
event.preventDefault();
consentForm.patch(`/management/interests/${interest.id}/consent/proponent`);
}}>
<Field label="Motivo do pedido de revogação" error={consentForm.errors.reason}>
<textarea className={control} minLength={10} maxLength={2000} required rows={3} value={consentForm.data.reason} onChange={(event) => consentForm.setData("reason", event.target.value)} />
</Field>
<button className={button} disabled={consentForm.processing}>Revogar autorização de partilha</button>
</form>
)}
</section>
<form
className="max-w-sm space-y-4"
onSubmit={(e) => {
@@ -103,17 +136,42 @@ export default function InterestDetail({ interest }: { interest: Interest }) {
value={form.data.status}
onChange={(e) => form.setData("status", e.target.value)}
>
{["received", "in_review", "contacted", "closed"].map((key) => (
{["received", "submitted", "in_review", "reviewed", "qualification", "qualified", "contacted", "contact_accepted", "referred", "due_diligence", "negotiation", "pending", "refused", "converted", "cancelled", "closed"].map((key) => (
<option key={key} value={key}>
{states[key]}
</option>
))}
</select>
</Field>
<Field label="Nota de acompanhamento" error={form.errors.note}>
<textarea className={control} rows={3} value={form.data.note} onChange={(e) => form.setData("note", e.target.value)} />
</Field>
<Field label="Próxima acção" error={form.errors.next_action}>
<input className={control} value={form.data.next_action} onChange={(e) => form.setData("next_action", e.target.value)} />
</Field>
<Field label="Prazo da próxima acção" error={form.errors.next_action_due_at}>
<input type="date" className={control} value={form.data.next_action_due_at} onChange={(e) => form.setData("next_action_due_at", e.target.value)} />
</Field>
<Field label="Responsável" error={form.errors.assigned_to}>
<select className={control} value={form.data.assigned_to} onChange={(e) => form.setData("assigned_to", e.target.value)}>
<option value="">Sem responsável</option>
{assignees.map((assignee) => <option key={assignee.id} value={assignee.id}>{assignee.name}</option>)}
</select>
</Field>
<button className={button} disabled={form.processing}>
{form.processing ? "A guardar…" : "Guardar estado"}
</button>
</form>
<section className="space-y-3">
<h2 className="font-semibold">Histórico do fluxo</h2>
{!history.length && <p>Sem alterações de estado registadas.</p>}
{history.map((entry, index) => (
<article key={`${entry.created_at}-${index}`} className="rounded border p-3">
<p>{entry.from_status ? `${states[entry.from_status] ?? entry.from_status} → ` : ""}{states[entry.to_status] ?? entry.to_status} · {dateTime(entry.created_at)}</p>
{entry.note && <p className="mt-1 whitespace-pre-wrap">{entry.note}</p>}
</article>
))}
</section>
</Management>
);
}