@@ -47,7 +47,14 @@ export type CanonicalOptions = {
|
||||
activities: {
|
||||
id: string;
|
||||
parent_id: string | null;
|
||||
sector_id: number;
|
||||
sector_id: number | null;
|
||||
code?: string;
|
||||
level?: number | null;
|
||||
path?: { id: string; code: string; label: string }[];
|
||||
display_label?: string;
|
||||
historical_only?: boolean;
|
||||
source_version?: string | null;
|
||||
edition?: string | null;
|
||||
label_pt_mz: string;
|
||||
}[];
|
||||
resources: Record<string, Resource[]>;
|
||||
@@ -924,23 +931,19 @@ export default function OpportunityCanonicalFields({
|
||||
label: c.full_name,
|
||||
}))
|
||||
: options.activities
|
||||
.filter((a) =>
|
||||
key === 'subsector_id'
|
||||
? options.activities.some(
|
||||
(root) =>
|
||||
root.sector_id ===
|
||||
Number(
|
||||
value.sector_id,
|
||||
) &&
|
||||
a.parent_id === root.id,
|
||||
)
|
||||
: a.parent_id ===
|
||||
value.subsector_id,
|
||||
)
|
||||
.map((a) => ({
|
||||
id: a.id,
|
||||
label: a.label_pt_mz,
|
||||
}));
|
||||
.filter((a) => {
|
||||
if (a.id === value[key]) return true;
|
||||
if (a.historical_only) return false;
|
||||
if (a.level) {
|
||||
return key === 'subsector_id'
|
||||
? a.level === 2 && a.code === '01' && a.sector_id === Number(value.sector_id)
|
||||
: a.level === 5 && a.code === '01120' && !!a.path?.some((p) => p.id === value.subsector_id);
|
||||
}
|
||||
return key === 'subsector_id'
|
||||
? options.activities.some((root) => root.sector_id === Number(value.sector_id) && a.parent_id === root.id)
|
||||
: a.parent_id === value.subsector_id;
|
||||
})
|
||||
.map((a) => ({ id: a.id, label: (a.display_label ?? a.label_pt_mz) + (a.historical_only ? ' — histórico preservado' : '') }));
|
||||
return (
|
||||
<label key={key} className="block">
|
||||
{labels[key]}
|
||||
@@ -969,6 +972,12 @@ export default function OpportunityCanonicalFields({
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{key === 'economic_activity_id' && options.activities.find((a) => a.id === value[key])?.level && (
|
||||
<p className="mt-1 text-sm" data-economic-path="five-levels">
|
||||
{options.activities.find((a) => a.id === value[key])?.path?.map((p) => `${p.code} — ${p.label}`).join(' → ')}
|
||||
{' · Exemplar eBAU; edição normativa não determinada; divergência 600/579 aberta.'}
|
||||
</p>
|
||||
)}
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export type ClassificationOptions = {
|
||||
dimensions: Record<string, string>;
|
||||
types: Record<string, string>;
|
||||
purposes: Record<string, string>;
|
||||
targets: Record<string, { id: string | number; label: string }[]>;
|
||||
targets: Record<string, { id: string | number; label: string; code?: string; level?: number | null; path?: { id: string; code: string; label: string }[]; source_version?: string | null; edition?: string | null }[]>;
|
||||
externalStates: string[];
|
||||
};
|
||||
const typeLabels: Record<string, string> = {
|
||||
@@ -61,7 +61,7 @@ const externalLabels: Record<string, string> = {
|
||||
expired: 'Caducado',
|
||||
};
|
||||
const help =
|
||||
'Associação, publicação e ato externo têm estados separados. Localização ou proximidade não concedem licença, benefício, terreno ou capacidade. Dados ausentes permanecem por determinar.';
|
||||
'Associação, publicação e ato externo têm estados separados. Localização ou proximidade não concedem licença, benefício, terreno ou capacidade. Dados ausentes permanecem por determinar. Os elos identificados como Modelo editorial não confirmam operadores, capacidade ou relações comerciais. O recorte CAE conserva cinco níveis; 600/579 permanece documentalmente aberto.';
|
||||
|
||||
export function ClassificationEditor({
|
||||
rows,
|
||||
@@ -193,6 +193,9 @@ export function ClassificationEditor({
|
||||
<option value="">
|
||||
Selecionar referência
|
||||
</option>
|
||||
{row.related_id && !(options.targets[row.classification.target_type] ?? []).some((t) => String(t.id) === String(row.related_id)) && (
|
||||
<option value={row.related_id}>Referência guardada, atualmente indisponível — {row.related_id}</option>
|
||||
)}
|
||||
{(
|
||||
options.targets[
|
||||
row.classification
|
||||
@@ -207,6 +210,9 @@ export function ClassificationEditor({
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{row.related_id && !(options.targets[row.classification.target_type] ?? []).some((t) => String(t.id) === String(row.related_id)) && (
|
||||
<span className="block text-sm">A referência deixou de estar disponível para novas escolhas. A relação histórica permanece guardada; não selecione outro valor para a recuperar.</span>
|
||||
)}
|
||||
{errors[
|
||||
`canonical.relations.${index}.related_id`
|
||||
] && (
|
||||
@@ -745,6 +751,7 @@ export function ClassificationReview({
|
||||
}
|
||||
|
||||
export type PublicClassification = {
|
||||
reference_path?: { id: string; code: string; label: string }[];
|
||||
dimension: string;
|
||||
target_type: string;
|
||||
target_id: string;
|
||||
@@ -784,7 +791,9 @@ export function ClassificationSummary({
|
||||
.filter((r) => r.dimension === dimension)
|
||||
.map((r, i) => (
|
||||
<p key={i} className="break-words">
|
||||
{r.label} · {classificationStates[r.state]}{' '}
|
||||
{r.reference_path?.length
|
||||
? r.reference_path.map((n) => `${n.code} — ${n.label}`).join(' → ')
|
||||
: r.label} · {classificationStates[r.state]}{' '}
|
||||
· {r.purpose_label ?? r.purpose} ·{' '}
|
||||
{r.source_reference || 'Fonte por indicar'}{' '}
|
||||
{r.citation} {r.production_stage} · Ato
|
||||
|
||||
Reference in New Issue
Block a user