Entrega dashboard e correccoes transversais preservando Ofertas instalado
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-15 18:56:39 +02:00
parent 1349789226
commit fb076c174f
117 changed files with 10380 additions and 1905 deletions
+14 -4
View File
@@ -2,16 +2,26 @@ import { useEffect, useState } from 'react';
import { newSubmissionKey } from '@/lib/portal-api';
export function useInterestDraft<T>(name: string, initial: T) {
const storage = 'investemoz-interest:' + name;
const [draft, setDraft] = useState<{ form: T; key: string }>(() => {
const read = () => {
try {
const value = JSON.parse(sessionStorage.getItem(storage) ?? 'null');
if (value?.form && typeof value.key === 'string') return value;
if (value?.form && typeof value.key === 'string')
return { ...value, storage } as {
form: T;
key: string;
storage: string;
};
} catch {
/* unavailable storage leaves the current form usable */
}
return { form: initial, key: newSubmissionKey() };
});
return { form: initial, key: newSubmissionKey(), storage };
};
const [draft, setDraft] = useState(read);
// Inertia can reuse this component for a different opportunity. Never write
// the previous opportunity's answers into the new opportunity's storage key.
if (draft.storage !== storage) setDraft(read());
useEffect(() => {
if (draft.storage !== storage) return;
try {
sessionStorage.setItem(storage, JSON.stringify(draft));
} catch {}