Preserve selected portfolio context through investment preparation

This commit is contained in:
2026-10-23 14:35:50 +02:00
parent 6948ed62fc
commit 3d877ec745
16 changed files with 271 additions and 28 deletions
+10
View File
@@ -1,6 +1,16 @@
const levels = ['province_id', 'district_id', 'admin_post_id', 'locality_id'];
const searchRoutes = ['/carteira', '/oportunidades', '/zonas', '/educacao'];
/** Carry the explicitly consulted portfolio origin and search geography into the existing preparation entry. */
export function investmentPreparationHref(opportunity: number, pageUrl: string, origin?: string | null): string {
const source = new URL(pageUrl, 'https://portal.invalid');
const inherited = source.searchParams.has('catalogue_query') ? new URLSearchParams(source.searchParams.get('catalogue_query')!) : source.searchParams;
const query = new URLSearchParams({source: `opportunity:${opportunity}`});
if (origin) query.set('from_dossier', origin);
for (const field of levels) if (inherited.get(field)) query.set(field, inherited.get(field)!);
return '/investimentos/iniciar?' + query.toString();
}
/** URL-scoped search context, never a saved investment or another browser tab. */
export function searchTerritoryHref(href: string, pageUrl: string): string {
const base = 'https://portal.invalid';