vrsao 2
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-08 14:02:01 +02:00
parent bdd766c68a
commit 1106509116
354 changed files with 48275 additions and 24635 deletions
@@ -148,23 +148,39 @@ export function SimulationBusinessPlan({
const importPlanFile = async (file: File | undefined) => {
if (!file) return;
if (file.size > MAX_BUSINESS_PLAN_SNAPSHOT_LENGTH) {
setSnapshotError('O ficheiro excede 60 KB. Seleccione um plano JSON exportado pelo InvestMoz dentro deste limite.');
setSnapshotError(
'O ficheiro excede 60 KB. Seleccione um plano JSON exportado pelo InvestMoz dentro deste limite.',
);
return;
}
try {
const source = await file.text();
const imported = restoreBusinessPlanSnapshot(source);
if (!imported) throw new Error('O ficheiro não contém um plano JSON reconhecido pelo InvestMoz.');
if (!imported)
throw new Error(
'O ficheiro não contém um plano JSON reconhecido pelo InvestMoz.',
);
savePlan(imported);
setSnapshotError('');
} catch (cause) {
setSnapshotError(cause instanceof Error ? cause.message : 'Não foi possível importar este plano.');
setSnapshotError(
cause instanceof Error
? cause.message
: 'Não foi possível importar este plano.',
);
}
};
const exportPlanJson = () => {
try {
const snapshotJson = serializeBusinessPlanSnapshot({ ...plan, currency });
const url = URL.createObjectURL(new Blob([snapshotJson], { type: 'application/json;charset=utf-8' }));
const snapshotJson = serializeBusinessPlanSnapshot({
...plan,
currency,
});
const url = URL.createObjectURL(
new Blob([snapshotJson], {
type: 'application/json;charset=utf-8',
}),
);
const link = document.createElement('a');
link.href = url;
link.download = 'plano-financeiro-investmoz.json';
@@ -173,7 +189,11 @@ export function SimulationBusinessPlan({
window.setTimeout(() => URL.revokeObjectURL(url), 1000);
setSnapshotError('');
} catch (cause) {
setSnapshotError(cause instanceof Error ? cause.message : 'Não foi possível exportar este plano.');
setSnapshotError(
cause instanceof Error
? cause.message
: 'Não foi possível exportar este plano.',
);
}
};
type ProductScheduleKey =
@@ -856,10 +876,27 @@ export function SimulationBusinessPlan({
<div className="my-3 flex flex-wrap items-end gap-3 rounded border p-3">
<label className="grid gap-1 text-sm">
Importar plano financeiro InvestMoz (.json, até 60 KB)
<input type="file" accept="application/json,.json" onChange={(event) => { void importPlanFile(event.currentTarget.files?.[0]); event.currentTarget.value = ''; }} />
<input
type="file"
accept="application/json,.json"
onChange={(event) => {
void importPlanFile(event.currentTarget.files?.[0]);
event.currentTarget.value = '';
}}
/>
</label>
<button type="button" className="rounded border px-3 py-2 text-sm" onClick={exportPlanJson}>Exportar plano JSON</button>
<span className="text-xs text-slate-600">O ficheiro é lido localmente. A importação substitui os pressupostos editáveis deste plano após validação do formato.</span>
<button
type="button"
className="rounded border px-3 py-2 text-sm"
onClick={exportPlanJson}
>
Exportar plano JSON
</button>
<span className="text-xs text-slate-600">
O ficheiro é lido localmente. A importação substitui os
pressupostos editáveis deste plano após validação do
formato.
</span>
</div>
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
<label className="block text-sm font-medium">