196 lines
7.0 KiB
TypeScript
196 lines
7.0 KiB
TypeScript
import { card, input } from '@/pages/investment/shared';
|
|
|
|
export const financialCategories: Record<string, string> = {
|
|
banking: 'Banca',
|
|
credit: 'Crédito e microfinanças',
|
|
investment: 'Gestão de investimento',
|
|
pensions: 'Fundos de pensões',
|
|
insurance: 'Seguros e resseguros',
|
|
intermediation: 'Mediação de seguros',
|
|
exchange: 'Câmbio',
|
|
payments: 'Pagamentos e serviços interbancários',
|
|
supervision: 'Supervisão',
|
|
other: 'Outras instituições',
|
|
};
|
|
export const financialTypes: Record<string, string> = {
|
|
commercial_bank: 'Banco comercial',
|
|
investment_bank: 'Banco de investimento',
|
|
bank: 'Banco (tipo não especificado)',
|
|
microbank: 'Microbanco',
|
|
cooperative: 'Cooperativa de crédito',
|
|
savings: 'Organização de poupança e empréstimo',
|
|
investment_manager: 'Gestora de fundos de investimento',
|
|
investment_company: 'Sociedade de investimento',
|
|
pension_manager: 'Gestora de fundos de pensões',
|
|
insurer: 'Seguradora',
|
|
reinsurer: 'Resseguradora',
|
|
microinsurer: 'Micro-seguradora',
|
|
broker: 'Corretora de seguros',
|
|
agent: 'Agente de seguros',
|
|
reinsurance_broker: 'Corretor de resseguro',
|
|
exchange_house: 'Casa de câmbio',
|
|
electronic_money: 'Instituição de moeda electrónica',
|
|
interbank: 'Serviços interbancários',
|
|
supervisor: 'Supervisor',
|
|
other: 'Outro tipo documentado',
|
|
};
|
|
export type Classification = {
|
|
institution_categories?: string[];
|
|
institution_types?: string[];
|
|
institution_services?: string[];
|
|
institution_status?: string;
|
|
successor_key?: string | null;
|
|
register_reference?: string | null;
|
|
source_document_name?: string | null;
|
|
source_document_sha256?: string | null;
|
|
aliases?: string[];
|
|
source_rows?: { id: string; section: string; text: string }[];
|
|
};
|
|
export const evidenceLabels: Record<string, string> = {
|
|
reported: 'Reportado no documento',
|
|
to_confirm: 'A confirmar',
|
|
historical: 'Referência histórica',
|
|
conflict: 'Informação divergente/identidade por confirmar',
|
|
unlocated: 'Localização por confirmar',
|
|
};
|
|
export function ClassificationSummary({ value }: { value: Classification }) {
|
|
return (
|
|
<section className={card}>
|
|
<h2>Categoria e tipo da instituição</h2>
|
|
<p>
|
|
Categorias:{' '}
|
|
{(value.institution_categories ?? [])
|
|
.map((k) => financialCategories[k] ?? k)
|
|
.join(' · ') || 'Por classificar'}
|
|
</p>
|
|
<p>
|
|
Tipos:{' '}
|
|
{(value.institution_types ?? [])
|
|
.map((k) => financialTypes[k] ?? k)
|
|
.join(' · ') || 'Por classificar'}
|
|
</p>
|
|
<p>
|
|
Situação segundo a fonte:{' '}
|
|
{value.institution_status === 'merged'
|
|
? 'Fundida/extinta segundo o documento; não apresentar como instituição activa'
|
|
: value.institution_status === 'historical'
|
|
? 'Registo histórico'
|
|
: value.institution_status === 'unknown'
|
|
? 'Situação actual por confirmar'
|
|
: 'Reportada no documento; não é confirmação independente de licença actual'}
|
|
{value.successor_key
|
|
? ` · Sucessora indicada: ${value.successor_key}`
|
|
: ''}
|
|
</p>
|
|
{value.register_reference && (
|
|
<p>
|
|
Referência de registo no documento:{' '}
|
|
{value.register_reference}
|
|
</p>
|
|
)}
|
|
<details>
|
|
<summary>
|
|
Rastrear o conteúdo até ao documento e à linha de origem
|
|
</summary>
|
|
<p>
|
|
{value.source_document_name} · SHA-256{' '}
|
|
{value.source_document_sha256}
|
|
</p>
|
|
{(value.source_rows ?? []).map((row) => (
|
|
<article key={row.id}>
|
|
<h3>{row.section}</h3>
|
|
<p>{row.id}</p>
|
|
<p>{row.text}</p>
|
|
</article>
|
|
))}
|
|
</details>
|
|
<p>
|
|
Categoria e presença física não confirmam cobertura de crédito,
|
|
oferta de seguro específica, garantia ou aceitação do processo.
|
|
</p>
|
|
</section>
|
|
);
|
|
}
|
|
export function ClassificationFields({
|
|
value,
|
|
change,
|
|
needs,
|
|
}: {
|
|
value: Classification;
|
|
change: (patch: Partial<Classification>) => void;
|
|
needs: Record<string, string>;
|
|
}) {
|
|
const multiple = (
|
|
key:
|
|
| 'institution_categories'
|
|
| 'institution_types'
|
|
| 'institution_services',
|
|
label: string,
|
|
options: Record<string, string>,
|
|
) => (
|
|
<label className="my-3 block">
|
|
{label}
|
|
<select
|
|
multiple
|
|
className={input}
|
|
value={value[key] ?? []}
|
|
onChange={(e) =>
|
|
change({
|
|
[key]: Array.from(
|
|
e.target.selectedOptions,
|
|
(o) => o.value,
|
|
),
|
|
})
|
|
}
|
|
>
|
|
{Object.entries(options).map(([id, title]) => (
|
|
<option key={id} value={id}>
|
|
{title}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</label>
|
|
);
|
|
return (
|
|
<details className={card}>
|
|
<summary>Categoria, tipo e serviço — Alterar</summary>
|
|
{multiple(
|
|
'institution_categories',
|
|
'Categorias documentadas',
|
|
financialCategories,
|
|
)}
|
|
{multiple(
|
|
'institution_types',
|
|
'Tipos documentados',
|
|
financialTypes,
|
|
)}
|
|
{multiple(
|
|
'institution_services',
|
|
'Serviços identificados (não é oferta garantida)',
|
|
needs,
|
|
)}
|
|
<label>
|
|
Situação
|
|
<select
|
|
className={input}
|
|
value={value.institution_status ?? 'unknown'}
|
|
onChange={(e) =>
|
|
change({ institution_status: e.target.value })
|
|
}
|
|
>
|
|
<option value="unknown">Por confirmar</option>
|
|
<option value="reported">Reportada no documento</option>
|
|
<option value="historical">Histórica</option>
|
|
<option value="merged">
|
|
Fundida/extinta segundo a fonte
|
|
</option>
|
|
</select>
|
|
</label>
|
|
<p>
|
|
As linhas originais e as classificações anteriores conservam-se
|
|
nas versões. Não complete lacunas por inferência.
|
|
</p>
|
|
</details>
|
|
);
|
|
}
|