Corrige validacao, recuperacao e acesso ao calculo do rascunho

This commit is contained in:
2026-10-08 18:07:29 +02:00
parent 1106509116
commit 51c7fb92b1
9 changed files with 1152 additions and 41 deletions
+16
View File
@@ -29,6 +29,22 @@ export function simulationApiErrorMessage(value: unknown): string | undefined {
: value.message;
}
/** Keep snapshot field errors attached to their original form fields. */
export function simulationApiFieldErrors(
value: unknown,
): Record<string, string> {
if (!isApiErrorV1(value)) return {};
const fields: Record<string, string> = {};
for (const [path, messages] of Object.entries(value.errors ?? {})) {
const key = path
.replace(/^(economic_snapshot|personal_snapshot)\./, '')
.split('.')[0];
if (/^[a-z][a-z0-9_]*$/.test(key) && messages.length)
fields[key] = messages.join(' ');
}
return fields;
}
/** Explain a failed status check without implying the accepted job was lost. */
export function simulationPollingFailureMessage(value: unknown): string {
return (