oportunidades 4
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-10 07:03:59 +02:00
parent e662230df7
commit 6ddafc95ba
179 changed files with 22750 additions and 933 deletions
+47 -7
View File
@@ -4,10 +4,15 @@ import type { Guidance } from './investor-guidance';
/** Carries only an account-scoped case identifier between modules; never a contact/document payload. */
export function JourneyCompanion() {
const { props, url } = usePage<{ auth: { user: { id: number } | null } }>();
const { props, url } = usePage<{
auth: { user: { id: number } | null };
investorPathEnabled?: boolean;
}>();
const actor = props.auth?.user?.id;
const [open, setOpen] = useState(false);
const [cases, setCases] = useState<{ id: string; title: string }[]>([]);
const [cases, setCases] = useState<
{ id: string; title: string; path_supported?: boolean }[]
>([]);
const [active, setActive] = useState('');
const [guidance, setGuidance] = useState<Guidance | null>(null);
const [message, setMessage] = useState('');
@@ -19,15 +24,27 @@ export function JourneyCompanion() {
if (!actor) return;
try {
const key = `investmoz-guidance-case:${actor}`;
const routeId = url.match(
/^\/balcao-virtual\/dossiers\/([a-f0-9-]{36})/i,
)?.[1];
const context = new URL(
url,
'https://investmoz.invalid',
).searchParams.get('context');
const pathId = props.investorPathEnabled
? url.match(/^\/investimentos\/([a-f0-9-]{36})/i)?.[1]
: null;
const routeId =
pathId ??
(props.investorPathEnabled &&
context &&
/^[a-f0-9-]{36}$/i.test(context)
? context
: null) ??
url.match(/^\/balcao-virtual\/dossiers\/([a-f0-9-]{36})/i)?.[1];
if (routeId) sessionStorage.setItem(key, routeId);
setActive(routeId ?? sessionStorage.getItem(key) ?? '');
} catch {
setMessage('Selecção de contexto disponível apenas nesta página.');
}
}, [actor, url]);
}, [actor, url, props.investorPathEnabled]);
useEffect(() => {
if (!open || !actor) return;
const controller = new AbortController();
@@ -42,7 +59,11 @@ export function JourneyCompanion() {
'Acompanhamento em preparação; os pedidos anteriores continuam no Balcão Virtual.',
);
return r.json() as Promise<{
cases: { id: string; title: string }[];
cases: {
id: string;
title: string;
path_supported?: boolean;
}[];
}>;
})
.then((data) => setCases(data.cases))
@@ -110,6 +131,25 @@ export function JourneyCompanion() {
</p>
) : (
<>
{props.investorPathEnabled && (
<Link
className="block underline"
href="/investimentos"
>
Os meus investimentos e próxima acção
</Link>
)}
{cases.some(
(item) =>
item.id === active && item.path_supported,
) && (
<Link
className="block font-semibold underline"
href={`/investimentos/${active}`}
>
Voltar ao percurso deste investimento
</Link>
)}
<label className="block">
Contexto do projecto
<select