@@ -1154,6 +1154,7 @@ export function SimulationForm() {
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
setReady(false);
|
||||
void (async () => {
|
||||
let local: SimulationDraft = {};
|
||||
const requestedDraftId = new URLSearchParams(
|
||||
@@ -1229,6 +1230,7 @@ export function SimulationForm() {
|
||||
}
|
||||
}
|
||||
if (payload.data) {
|
||||
if (cancelled) return;
|
||||
draftIdRef.current = payload.data.id;
|
||||
draftEtagRef.current = response.headers.get('ETag');
|
||||
setDraftVersionNo(payload.data.version_no);
|
||||
@@ -1475,7 +1477,7 @@ export function SimulationForm() {
|
||||
]);
|
||||
|
||||
async function returnToInvestment() {
|
||||
if (!contextId || !draftIdRef.current) return;
|
||||
if (!ready || !contextId || !draftIdRef.current) return;
|
||||
setContinuityError('');
|
||||
try {
|
||||
await saveQueueRef.current;
|
||||
@@ -1496,8 +1498,14 @@ export function SimulationForm() {
|
||||
'Não foi possível recuperar o rascunho guardado.',
|
||||
);
|
||||
if (
|
||||
saved.data.economic_snapshot.financial_tools_snapshot !==
|
||||
draft.financial_tools_snapshot
|
||||
simulationDraftFingerprint(
|
||||
restoreSimulationDraft(
|
||||
saved.data.economic_snapshot,
|
||||
Array.isArray(saved.data.personal_snapshot)
|
||||
? {}
|
||||
: saved.data.personal_snapshot,
|
||||
),
|
||||
) !== simulationDraftFingerprint(draft)
|
||||
)
|
||||
throw new Error(
|
||||
'Aguarde a gravação das entradas da ferramenta e tente novamente.',
|
||||
@@ -1912,6 +1920,7 @@ export function SimulationForm() {
|
||||
value: string | string[],
|
||||
label?: string | string[],
|
||||
) {
|
||||
if (!ready) return;
|
||||
setContinueLaterSaved(false);
|
||||
setServerFieldErrors((previous) => {
|
||||
const next = { ...previous };
|
||||
@@ -2035,6 +2044,7 @@ export function SimulationForm() {
|
||||
}
|
||||
|
||||
function navigate(nextStep: number) {
|
||||
if (!ready) return;
|
||||
setOpenedTool(null);
|
||||
if (nextStep > step) {
|
||||
for (let index = step; index < nextStep; index++) {
|
||||
@@ -2390,7 +2400,12 @@ export function SimulationForm() {
|
||||
<section
|
||||
className="space-y-6 rounded-xl border bg-white p-4 sm:p-6"
|
||||
aria-labelledby="simulator-step-title"
|
||||
aria-busy={!ready}
|
||||
>
|
||||
{!ready && (
|
||||
<p role="status">A recuperar o rascunho. Aguarde para editar.</p>
|
||||
)}
|
||||
<fieldset disabled={!ready} className="min-w-0 space-y-6">
|
||||
{canSavePersonalData && draftVersionNo && draftIdRef.current && (
|
||||
<a
|
||||
className="inline-block underline"
|
||||
@@ -4336,6 +4351,7 @@ export function SimulationForm() {
|
||||
associados à conta. A submissão formal ainda não está disponível
|
||||
neste formulário.
|
||||
</p>
|
||||
</fieldset>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user