fix: preserve territorial search across investment catalogues

This commit is contained in:
2026-10-22 12:52:52 +02:00
parent 5f4eb5cfaa
commit 9ac623a433
14 changed files with 118 additions and 24 deletions
+6 -4
View File
@@ -1,4 +1,5 @@
import { Link, useForm } from '@inertiajs/react';
import { Link, useForm, usePage } from '@inertiajs/react';
import { searchTerritoryHref } from '@/lib/search-territory';
import { catalogueDetailHref } from '@/lib/catalogue-context';
import { Management } from '../management/shared';
import type { Paginated } from '../management/shared';
@@ -35,6 +36,7 @@ export default function Index({
locality_id: filters.locality_id ?? '',
});
const base = management ? '/management/portfolio' : '/carteira';
const { url } = usePage();
const Frame = management ? Management : Layout;
return (
<Frame title="Corredores, clusters e projectos âncora">
@@ -151,7 +153,7 @@ export default function Index({
(r.corridor_id || r.cluster_id || r.project_id) && (
<Link
className="ml-4 underline"
href={`/oportunidades?${new URLSearchParams(r.corridor_id ? { corridor_id: r.corridor_id } : r.cluster_id ? { cluster_id: r.cluster_id } : { project_id: r.project_id! })}`}
href={searchTerritoryHref(`/oportunidades?${new URLSearchParams(r.corridor_id ? { corridor_id: r.corridor_id } : r.cluster_id ? { cluster_id: r.cluster_id } : { project_id: r.project_id! })}`, url)}
>
Ver oportunidades associadas
</Link>
@@ -174,10 +176,10 @@ export default function Index({
aria-label="Alternativas de exploração"
className="flex flex-wrap gap-4"
>
<Link className="underline" href="/oportunidades">
<Link className="underline" href={searchTerritoryHref('/oportunidades', url)}>
Ver oportunidades publicadas
</Link>
<Link className="underline" href="/zonas">
<Link className="underline" href={searchTerritoryHref('/zonas', url)}>
Consultar ZEE, ZFI e parques
</Link>
<Link className="underline" href="/Simulador">
+4 -3
View File
@@ -1,6 +1,7 @@
import { Link, useForm, router, usePage } from '@inertiajs/react';
import { useState } from 'react';
import { catalogueReturnHref } from '@/lib/catalogue-context';
import { searchTerritoryHref } from '@/lib/search-territory';
import InvestmentMapPanel from '@/components/investment-map-panel';
import StructureGeographyPanel, {
type StructureGeography,
@@ -190,7 +191,7 @@ function Editor({
</h2>
{zones.map((z) => (
<p key={z.id}>
<Link className="underline" href={`/zonas/${z.id}`}>
<Link className="underline" href={searchTerritoryHref(`/zonas/${z.id}`, pageUrl)}>
{z.name}
</Link>{' '}
· {z.association_type} · Fonte: {z.source_reference}
@@ -297,7 +298,7 @@ function Editor({
<article key={opportunity.id}>
<Link
className="font-semibold underline"
href={`/oportunidades/${opportunity.slug}?from_dossier=${record.id}`}
href={searchTerritoryHref(`/oportunidades/${opportunity.slug}?from_dossier=${record.id}`, pageUrl)}
>
{opportunity.title}
</Link>
@@ -485,7 +486,7 @@ function Editor({
{kind(r)}:{' '}
<Link
className="underline"
href={`${base}/${r.id}${management ? '' : `?from=${record.id}`}`}
href={searchTerritoryHref(`${base}/${r.id}${management ? '' : `?from=${record.id}`}`, pageUrl)}
>
{r.title}
</Link>