Reconciliar fontes instaladas 423bd512d8c5 com main

This commit is contained in:
2026-10-20 14:45:19 +02:00
parent 507387502c
commit 9ab721c97f
108 changed files with 2766 additions and 494 deletions
@@ -1,3 +1,4 @@
import { useInterestDraft } from '@/hooks/use-interest-draft';
import { useRef, useState } from 'react';
import { Link } from '@inertiajs/react';
import type { FormEvent } from 'react';
@@ -38,7 +39,7 @@ export default function BusinessInterest({
returnUrl = '/negocios',
countries,
}: Props) {
const [form, setForm] = useState<Form>({
const draft = useInterestDraft<Form>('business:' + record.id, {
declared_origin_country_code: '',
fullName: '',
email: '',
@@ -52,11 +53,12 @@ export default function BusinessInterest({
privacyConsent: false,
shareWithProponent: false,
});
const {form, setForm} = draft;
const [busy, setBusy] = useState(false);
const [error, setError] = useState('');
const [fieldErrors, setFieldErrors] = useState<Partial<Record<keyof Form, string>>>({});
const [receipt, setReceipt] = useState('');
const key = useRef(newSubmissionKey());
const key = useRef(draft.key);
const update = <K extends keyof Form>(field: K, value: Form[K]) => {
setForm((current) => ({ ...current, [field]: value }));
setFieldErrors((current) => ({ ...current, [field]: undefined }));
@@ -102,6 +104,7 @@ export default function BusinessInterest({
existingBusinessId: record.id,
}),
});
if (response.status === 401) { draft.authenticate(); return; }
const data = await response.json();
if (!response.ok) {
const errors: Partial<Record<keyof Form, string>> = {};
@@ -117,6 +120,7 @@ export default function BusinessInterest({
return;
}
setFieldErrors({});
draft.clear();
setReceipt(data.data.reference);
key.current = newSubmissionKey();
} catch (cause) {
@@ -140,7 +144,7 @@ export default function BusinessInterest({
{receipt ? (
<section className={card} role="status">
<h2 className="text-xl font-bold">Pedido recebido</h2>
<p>Referência: {receipt}</p>
<p>Referência: {receipt}</p><Link href="/investidor/manifestacoes" className="underline">Acompanhar manifestações</Link>
<p>
A equipa fará a triagem antes de qualquer partilha com o
proponente.