fix: keep public catalogue selectors independent of opportunity results
This commit is contained in:
@@ -102,6 +102,16 @@ export default function Catalogue({
|
||||
),
|
||||
});
|
||||
const view = String(filters.view ?? 'grid');
|
||||
const selectedStructures = [
|
||||
...(references.zones ?? []).filter((zone) =>
|
||||
['park_id', 'zee_id', 'zfi_id'].some((key) => filters[key] === zone.id),
|
||||
).map((zone) => ({ ...zone, url: `/zonas/${zone.id}` })),
|
||||
...(['clusters', 'corridors', 'projects'] as const).flatMap((group) =>
|
||||
references[group].filter((record) => filters[
|
||||
{ clusters: 'cluster_id', corridors: 'corridor_id', projects: 'project_id' }[group]
|
||||
] === record.id),
|
||||
),
|
||||
];
|
||||
const [territoryPath, setTerritoryPath] = useState(territorySelection);
|
||||
const [saved, setSaved] = useState(favourites);
|
||||
const [selected, setSelected] = useState<number[]>([]);
|
||||
@@ -362,6 +372,17 @@ export default function Catalogue({
|
||||
total={results.total}
|
||||
retry={() => runSearch()}
|
||||
/>
|
||||
{!searchLoading && !searchError && results.total === 0 && selectedStructures.length > 0 && (
|
||||
<section className={card} aria-label="Estrutura seleccionada">
|
||||
<p className="font-semibold">Sem oportunidades publicadas associadas com estes filtros.</p>
|
||||
<p>A estrutura continua disponível para consulta. A sua selecção não confirma benefícios nem disponibilidade para investimento.</p>
|
||||
{selectedStructures.map((record) => (
|
||||
record.url ? <Link key={record.id} className="block underline" href={searchTerritoryHref(record.url, page.url)}>
|
||||
Consultar ficha: {record.name}
|
||||
</Link> : <p key={record.id}>{record.name} — sem ficha pública detalhada disponível.</p>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
{!searchLoading &&
|
||||
!searchError &&
|
||||
|
||||
@@ -19,6 +19,7 @@ export type Option = {
|
||||
export type Entity = {
|
||||
id: string;
|
||||
name: string;
|
||||
url?: string | null;
|
||||
dossiers?: { id: string; title: string; source: string }[];
|
||||
geography?: StructureGeography | null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user