Mapa de erros 4.2: fundos mostram primeiro o local pesquisado
Numa pesquisa por cobertura, cada instituição listava todos os balcões do país sem destacar a província escolhida. Passa a mostrar primeiro a sede e os balcões do local pesquisado (ou a indicação de que não há), e os restantes numa secção «Outras localizações», agrupados por província. Notas de recolha que não são moradas («Não encontrei agência…», «Ver secção 7…») deixam de ser mostradas. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jm
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
publicInstitutionContacts,
|
||||
publicInstitutionLocations,
|
||||
matchingInstitutionLocations,
|
||||
institutionLocationsByPlace,
|
||||
} from "@/lib/funding-public-presentation";
|
||||
import { financialCategories, financialTypes } from "@/components/funding-classification";
|
||||
import { card, input, button } from "@/pages/investment/shared";
|
||||
@@ -500,14 +501,20 @@ export function InstitutionFields({
|
||||
</section>
|
||||
);
|
||||
}
|
||||
const locationRole = (role: string) =>
|
||||
role === "headquarters" ? "Sede: " : role === "branch" ? "Balcão: " : "";
|
||||
|
||||
export function InstitutionView({
|
||||
value,
|
||||
compact = false,
|
||||
physicalTerritory,
|
||||
focusTerritory,
|
||||
}: {
|
||||
value: InstitutionDetails & { title?: string; summary?: string };
|
||||
compact?: boolean;
|
||||
physicalTerritory?: string;
|
||||
/** Searched place (coverage search): its points first, the rest grouped by province. */
|
||||
focusTerritory?: string;
|
||||
}) {
|
||||
const presentation = fundingPublicPresentation({
|
||||
...value,
|
||||
@@ -533,6 +540,10 @@ export function InstitutionView({
|
||||
})),
|
||||
)
|
||||
: locations;
|
||||
const byPlace =
|
||||
compact && !physicalTerritory && focusTerritory
|
||||
? institutionLocationsByPlace(value.locations, focusTerritory)
|
||||
: null;
|
||||
const category = (value.institution_categories ?? [])
|
||||
.map((k) => financialCategories[k])
|
||||
.filter(Boolean)
|
||||
@@ -640,7 +651,49 @@ export function InstitutionView({
|
||||
Presença física por confirmar no local escolhido.
|
||||
</p>
|
||||
)}
|
||||
{visibleLocations.length > 0 && (
|
||||
{byPlace && (
|
||||
<div className="space-y-2">
|
||||
<h3 className="font-semibold">Localização no local pesquisado</h3>
|
||||
{byPlace.local.length > 0 ? (
|
||||
<ul className="space-y-1">
|
||||
{byPlace.local.map((l, i) => (
|
||||
<li key={i}>
|
||||
{locationRole(l.role)}
|
||||
{l.address}
|
||||
{l.hours ? " · " + l.hours : ""}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p>Sem sede ou balcão documentado no local pesquisado.</p>
|
||||
)}
|
||||
{byPlace.others.length > 0 && (
|
||||
<details>
|
||||
<summary className="cursor-pointer underline">
|
||||
Outras localizações (
|
||||
{byPlace.others.reduce((n, g) => n + g.items.length, 0)})
|
||||
</summary>
|
||||
<div className="mt-2 space-y-2">
|
||||
{byPlace.others.map((group) => (
|
||||
<div key={group.province}>
|
||||
<h4 className="font-medium">{group.province}</h4>
|
||||
<ul className="space-y-1">
|
||||
{group.items.map((l, i) => (
|
||||
<li key={i}>
|
||||
{locationRole(l.role)}
|
||||
{l.address}
|
||||
{l.hours ? " · " + l.hours : ""}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{!byPlace && visibleLocations.length > 0 && (
|
||||
<div>
|
||||
<h3 className="font-semibold">
|
||||
{physicalTerritory && compact
|
||||
|
||||
Reference in New Issue
Block a user