Unify institution profiles and reduce primary menu to six groups
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
import {
|
||||
ClassificationFields,
|
||||
ClassificationSummary,
|
||||
evidenceLabels,
|
||||
type Classification,
|
||||
} from '@/components/funding-classification';
|
||||
import {fundingPublicPresentation} from '@/lib/funding-public-presentation';
|
||||
import {
|
||||
fundingPublicPresentation,
|
||||
publicInstitutionContacts,
|
||||
publicInstitutionLocations,
|
||||
} from '@/lib/funding-public-presentation';
|
||||
import {
|
||||
financialCategories,
|
||||
financialTypes,
|
||||
} from '@/components/funding-classification';
|
||||
import { card, input, button } from '@/pages/investment/shared';
|
||||
|
||||
export type FundingSource = {
|
||||
@@ -552,135 +559,158 @@ export function InstitutionFields({
|
||||
</section>
|
||||
);
|
||||
}
|
||||
function Source({value}:{value:FundingSource}){return <>{value.source_url&&<details><summary>Informação institucional</summary><a className="underline" href={value.source_url} target="_blank" rel="noopener noreferrer">Consultar informação da entidade</a><p>Consulta em {value.checked_on}.</p></details>}{value.evidence_status==='historical'&&<p>Informação histórica.</p>}{value.evidence_status==='conflict'&&<p>Informação por esclarecer junto da instituição.</p>}</>;}
|
||||
export function InstitutionView({ value }: { value: InstitutionDetails }) {
|
||||
export function InstitutionView({
|
||||
value,
|
||||
compact = false,
|
||||
}: {
|
||||
value: InstitutionDetails & { title?: string; summary?: string };
|
||||
compact?: boolean;
|
||||
}) {
|
||||
const presentation = fundingPublicPresentation({
|
||||
...value,
|
||||
title: value.title ?? '',
|
||||
summary: value.summary ?? '',
|
||||
kind: 'institution',
|
||||
}),
|
||||
contacts = publicInstitutionContacts(value.contacts),
|
||||
locations = publicInstitutionLocations(value.locations);
|
||||
const category = (value.institution_categories ?? [])
|
||||
.map((k) => financialCategories[k])
|
||||
.filter(Boolean)
|
||||
.join(' · '),
|
||||
types = (value.institution_types ?? [])
|
||||
.map((k) => financialTypes[k])
|
||||
.filter(Boolean)
|
||||
.join(' · ');
|
||||
const urls = new Set<string>(
|
||||
compact
|
||||
? []
|
||||
: presentation.products
|
||||
.map((p) => p.url)
|
||||
.filter((url): url is string => !!url),
|
||||
);
|
||||
const sites = contacts
|
||||
.filter((c) => c.kind === 'website')
|
||||
.filter((c) => {
|
||||
if (urls.has(c.value)) return false;
|
||||
urls.add(c.value);
|
||||
return true;
|
||||
});
|
||||
return (
|
||||
<section className={card}>
|
||||
<h2>Instituição financeira</h2>
|
||||
<ClassificationSummary value={value} />
|
||||
{!value.institution_types?.length && (
|
||||
<section className="space-y-4" aria-label="Informação da instituição">
|
||||
{!compact && (
|
||||
<h2 className="text-lg font-semibold">
|
||||
Instituição financeira
|
||||
</h2>
|
||||
)}
|
||||
<div>
|
||||
<h3 className="font-semibold">Descrição</h3>
|
||||
<p>{presentation.description}</p>
|
||||
</div>
|
||||
{(category || types) && (
|
||||
<p>
|
||||
Natureza:{' '}
|
||||
{
|
||||
(
|
||||
{
|
||||
bank: 'Banco',
|
||||
credit: 'Instituição de crédito',
|
||||
microfinance: 'Microfinanças',
|
||||
investment_fund: 'Fundo de investimento',
|
||||
development:
|
||||
'Agência de desenvolvimento/financiamento',
|
||||
other: 'Outra natureza documentada',
|
||||
unknown: 'Por confirmar',
|
||||
} as Record<string, string>
|
||||
)[value.institution_nature]
|
||||
}
|
||||
{category}
|
||||
{category && types ? ': ' : ''}
|
||||
{types}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<h3>Contactos</h3>
|
||||
{value.contacts.length === 0 && <p>Contactos por confirmar.</p>}
|
||||
{value.contacts.map((c, i) => (
|
||||
<article key={i}>
|
||||
<p>
|
||||
{c.kind === 'website' ? (
|
||||
<a
|
||||
className="underline"
|
||||
href={c.value}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{c.value}
|
||||
</a>
|
||||
) : (
|
||||
c.value
|
||||
)}
|
||||
</p>
|
||||
<Source value={c} />
|
||||
</article>
|
||||
))}
|
||||
<h3>Sede e balcões — presença física</h3>
|
||||
{value.locations.length === 0 && (
|
||||
<p>Localização física por confirmar.</p>
|
||||
{['historical', 'merged'].includes(
|
||||
value.institution_status ?? '',
|
||||
) && <p>Instituição histórica ou integrada noutra entidade.</p>}
|
||||
<div>
|
||||
<h3 className="font-semibold">Produtos e serviços</h3>
|
||||
{presentation.products.length ? (
|
||||
<ul className="list-disc space-y-2 pl-5">
|
||||
{presentation.products.map((p) => (
|
||||
<li key={p.title}>
|
||||
{!compact && p.url ? (
|
||||
<a
|
||||
className="font-semibold underline"
|
||||
href={p.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{p.title}
|
||||
</a>
|
||||
) : (
|
||||
<strong>{p.title}</strong>
|
||||
)}
|
||||
{p.detail ? ': ' + p.detail : ''}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : presentation.services.length ? (
|
||||
<p>{presentation.services.join(' · ')}</p>
|
||||
) : null}
|
||||
</div>
|
||||
{!compact &&
|
||||
(sites.length > 0 ||
|
||||
contacts.some((c) => c.kind !== 'website')) && (
|
||||
<div>
|
||||
<h3 className="font-semibold">Contactos</h3>
|
||||
<ul className="space-y-1">
|
||||
{sites.map((c) => (
|
||||
<li key={c.value}>
|
||||
<a
|
||||
className="underline"
|
||||
href={c.value}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Website
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
{contacts
|
||||
.filter((c) => c.kind !== 'website')
|
||||
.map((c) => (
|
||||
<li key={c.kind + c.value}>
|
||||
{c.kind === 'email' ? (
|
||||
<a
|
||||
className="underline"
|
||||
href={'mailto:' + c.value}
|
||||
>
|
||||
{c.value}
|
||||
</a>
|
||||
) : c.kind === 'phone' ? (
|
||||
<a
|
||||
className="underline"
|
||||
href={
|
||||
'tel:' +
|
||||
c.value.replace(
|
||||
/[^+0-9]/g,
|
||||
'',
|
||||
)
|
||||
}
|
||||
>
|
||||
{c.value}
|
||||
</a>
|
||||
) : (
|
||||
c.value
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
{!compact && locations.length > 0 && (
|
||||
<div>
|
||||
<h3 className="font-semibold">Localização</h3>
|
||||
<ul className="space-y-1">
|
||||
{locations.map((l, i) => (
|
||||
<li key={i}>
|
||||
{l.role === 'headquarters'
|
||||
? 'Sede: '
|
||||
: l.role === 'branch'
|
||||
? 'Balcão: '
|
||||
: ''}
|
||||
{l.address}
|
||||
{l.hours ? ' · ' + l.hours : ''}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
{value.locations.map((l, i) => (
|
||||
<article key={i}>
|
||||
<p>
|
||||
{l.role === 'headquarters'
|
||||
? 'Sede'
|
||||
: l.role === 'branch'
|
||||
? 'Balcão'
|
||||
: 'Ponto de contacto institucional'}
|
||||
: {l.label && !/^(Morada|Localização).*(documento|fonte)/i.test(l.label) ? l.label+' · ' : ''}{l.address}
|
||||
</p>
|
||||
<p>
|
||||
{l.territory_path?.map((n) => n.name).join(' / ') ||
|
||||
'Localização detalhada a confirmar'}
|
||||
</p>
|
||||
{l.location_text && (
|
||||
<p>Local indicado: {l.location_text}</p>
|
||||
)}
|
||||
{l.hours && (
|
||||
<p>
|
||||
Horário de atendimento:{' '}
|
||||
{l.hours}
|
||||
</p>
|
||||
)}
|
||||
<Source value={l} />
|
||||
</article>
|
||||
))}
|
||||
<h3>Produtos e serviços</h3>
|
||||
{value.products.length === 0 && (
|
||||
<p>
|
||||
{fundingPublicPresentation({...value,title:"",kind:"institution",summary:""}).services.join(" · ") || "Consulte as soluções disponíveis junto da instituição."}
|
||||
</p>
|
||||
)}
|
||||
{value.products.map((p) => (
|
||||
<article className={card} key={p.code}>
|
||||
<h4>{p.title}</h4>
|
||||
<p>{p.instrument}</p>
|
||||
<p>
|
||||
Cobertura do financiamento:{' '}
|
||||
{p.coverage === 'national'
|
||||
? 'Nacional, segundo a fonte'
|
||||
: p.coverage === 'territorial'
|
||||
? 'Locais documentados'
|
||||
: 'Por confirmar'}{' '}
|
||||
· {p.coverage_text}
|
||||
</p>
|
||||
{p.territory_paths?.map((path, i) => (
|
||||
<p key={i}>{path.map((n) => n.name).join(' / ')}</p>
|
||||
))}
|
||||
<p>Condições: {p.conditions || 'Por confirmar'}</p>
|
||||
<p>
|
||||
Montantes/moeda/prazos: {p.amounts || 'Por confirmar'}
|
||||
</p>
|
||||
<p>
|
||||
Disponibilidade:{' '}
|
||||
{p.availability === 'unknown'
|
||||
? 'Por confirmar'
|
||||
: p.availability === 'closed'
|
||||
? 'Encerrada segundo a fonte'
|
||||
: 'Oferta identificada na fonte; confirmar condições actuais com a instituição'}
|
||||
</p>
|
||||
{p.contact_url && (
|
||||
<a
|
||||
href={p.contact_url}
|
||||
className="underline"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Contactar/consultar o produto
|
||||
</a>
|
||||
)}
|
||||
<Source value={p} />
|
||||
</article>
|
||||
))}
|
||||
<p>
|
||||
Uma referência não é elegibilidade confirmada, aprovação nem
|
||||
garantia de financiamento. O portal não envia pedidos ou dados à
|
||||
instituição.
|
||||
</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -200,11 +200,9 @@ export function PortalGroupedMenu() {
|
||||
{groups
|
||||
.filter((group) =>
|
||||
[
|
||||
'procurement-area',
|
||||
'discovery',
|
||||
'realization',
|
||||
'support',
|
||||
'work',
|
||||
].includes(group.id),
|
||||
)
|
||||
.map((group) => (
|
||||
@@ -260,7 +258,9 @@ export function PortalGroupedMenu() {
|
||||
<DropdownMenuTrigger
|
||||
className="tempo-nav-trigger"
|
||||
data-current-group={
|
||||
institutionalCurrent || undefined
|
||||
institutionalCurrent ||
|
||||
current === 'work' ||
|
||||
undefined
|
||||
}
|
||||
>
|
||||
Mais
|
||||
@@ -310,6 +310,17 @@ export function PortalGroupedMenu() {
|
||||
</DropdownMenuItem>
|
||||
),
|
||||
)}
|
||||
{groups
|
||||
.filter((group) => group.id === 'work')
|
||||
.map((group) => (
|
||||
<Fragment key={group.id}>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>
|
||||
{t(group.label)}
|
||||
</DropdownMenuLabel>
|
||||
{items(group.children ?? [])}
|
||||
</Fragment>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user