@@ -0,0 +1,474 @@
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { useRef } from 'react';
|
||||
|
||||
type Profile = {
|
||||
model: string;
|
||||
fields: Record<string, string>;
|
||||
operation_countries: string[];
|
||||
activities: Record<string, string>;
|
||||
activity_basis: string;
|
||||
documents: Record<string, string>;
|
||||
};
|
||||
export type FintechView = {
|
||||
record: { sha256: string; saved_at: string; profile: Profile } | null;
|
||||
fields: Record<string, string>;
|
||||
activities: Record<string, string>;
|
||||
countries: { code: string; name: string }[];
|
||||
requirements: {
|
||||
code: string;
|
||||
activity: string;
|
||||
state: string;
|
||||
basis: string;
|
||||
limit: string;
|
||||
}[];
|
||||
documents: {
|
||||
code: string;
|
||||
stage: string;
|
||||
label: string;
|
||||
document_id: string | null;
|
||||
applicability: string;
|
||||
action: string;
|
||||
}[];
|
||||
affected_reviews: string[];
|
||||
limits: string[];
|
||||
guidance: {
|
||||
stage: string;
|
||||
recommendations: { code: string; explanation: string }[];
|
||||
}[];
|
||||
guidance_version: string;
|
||||
};
|
||||
|
||||
export default function FintechInvestment({
|
||||
data,
|
||||
caseId,
|
||||
version,
|
||||
canWrite,
|
||||
documents,
|
||||
simulator,
|
||||
fromArticle,
|
||||
}: {
|
||||
data: FintechView;
|
||||
caseId: string;
|
||||
version: number;
|
||||
canWrite: boolean;
|
||||
documents: { document_id: string; file_name: string }[];
|
||||
simulator: string | null;
|
||||
fromArticle: boolean;
|
||||
}) {
|
||||
const form = useForm<{ version: number; profile: Profile }>({
|
||||
version,
|
||||
profile: {
|
||||
model: data.record?.profile.model ?? 'undetermined',
|
||||
fields: data.record?.profile.fields ?? {},
|
||||
operation_countries: data.record?.profile.operation_countries ?? [],
|
||||
activities: data.record?.profile.activities ?? {},
|
||||
activity_basis: data.record?.profile.activity_basis ?? '',
|
||||
documents: data.record?.profile.documents ?? {},
|
||||
},
|
||||
});
|
||||
const errors = form.errors as Record<string, string>;
|
||||
const errorSummary = useRef<HTMLDivElement>(null);
|
||||
const set = <K extends keyof Profile>(key: K, value: Profile[K]) =>
|
||||
form.setData('profile', { ...form.data.profile, [key]: value });
|
||||
const errorLabel = (field: string) => {
|
||||
if (field.startsWith('profile.fields.'))
|
||||
return data.fields[field.slice(15)] ?? 'Caracterização';
|
||||
if (field.startsWith('profile.documents.'))
|
||||
return (
|
||||
data.documents.find((d) => d.code === field.slice(18))?.label ??
|
||||
'Documento'
|
||||
);
|
||||
if (field.startsWith('profile.operation_countries'))
|
||||
return 'Países de operação declarados';
|
||||
return (
|
||||
(
|
||||
{
|
||||
version: 'Versão do dossier',
|
||||
'profile.model': 'Natureza do modelo',
|
||||
'profile.activity_basis': 'Fundamento das atividades',
|
||||
} as Record<string, string>
|
||||
)[field] ?? 'Caracterização'
|
||||
);
|
||||
};
|
||||
const status: Record<string, string> = {
|
||||
applicable: 'Aplicável à preparação do enquadramento',
|
||||
dispensed: 'Dispensado deste levantamento, com fundamento declarado',
|
||||
undetermined: 'Por determinar',
|
||||
};
|
||||
return (
|
||||
<section
|
||||
aria-labelledby="fintech-title"
|
||||
className="space-y-4 rounded-xl border p-4"
|
||||
>
|
||||
<h2 id="fintech-title" className="text-xl font-semibold">
|
||||
Caracterização Fintech no mesmo dossier
|
||||
</h2>
|
||||
<p>
|
||||
Preparação incompleta é permitida. Os estados, as cinco fases e
|
||||
as 19 etapas do percurso mantêm-se. A declaração do modelo não é
|
||||
classificação jurídica nem licença.
|
||||
</p>
|
||||
<details open={!!data.record || fromArticle}>
|
||||
<summary className="cursor-pointer underline">
|
||||
Preparar ou consultar este investimento como Fintech
|
||||
</summary>
|
||||
{data.record && (
|
||||
<p className="my-3 text-sm">
|
||||
Caracterização recuperada · {data.record.saved_at}
|
||||
</p>
|
||||
)}
|
||||
{!!data.affected_reviews.length && (
|
||||
<p role="status">
|
||||
Rever apenas {data.affected_reviews.join(', ')}: os
|
||||
pressupostos desse âmbito mudaram. Os pareceres
|
||||
anteriores permanecem no histórico.
|
||||
</p>
|
||||
)}
|
||||
<form
|
||||
className="mt-4 space-y-5"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
form.transform((value) => ({ ...value, version }));
|
||||
form.post(`/investimentos/${caseId}/fintech`, {
|
||||
preserveScroll: true,
|
||||
onError: () =>
|
||||
requestAnimationFrame(() =>
|
||||
errorSummary.current?.focus(),
|
||||
),
|
||||
});
|
||||
}}
|
||||
>
|
||||
{!!Object.keys(errors).length && (
|
||||
<div
|
||||
ref={errorSummary}
|
||||
tabIndex={-1}
|
||||
role="alert"
|
||||
className="rounded border border-red-700 p-3"
|
||||
>
|
||||
<p>
|
||||
Não foi possível guardar. Os dados preenchidos
|
||||
foram preservados.
|
||||
</p>
|
||||
<ul>
|
||||
{Object.entries(errors).map(
|
||||
([field, message]) => (
|
||||
<li key={field}>
|
||||
{errorLabel(field)}: {message}
|
||||
</li>
|
||||
),
|
||||
)}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
<fieldset
|
||||
disabled={!canWrite || form.processing}
|
||||
className="space-y-4 disabled:opacity-80"
|
||||
>
|
||||
<legend className="font-semibold">
|
||||
Modelo declarado
|
||||
</legend>
|
||||
<label className="grid gap-1">
|
||||
Natureza do modelo
|
||||
<select
|
||||
className="w-full rounded border p-2"
|
||||
value={form.data.profile.model}
|
||||
onChange={(e) => set('model', e.target.value)}
|
||||
>
|
||||
<option value="undetermined">
|
||||
Por determinar
|
||||
</option>
|
||||
<option value="technology_provider">
|
||||
Fornecedor de tecnologia, sem presumir
|
||||
atividade financeira reservada
|
||||
</option>
|
||||
<option value="financial_operator">
|
||||
Operador de serviços financeiros declarado,
|
||||
sujeito a enquadramento concreto
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{Object.entries(data.fields).map(([key, label]) => (
|
||||
<label key={key} className="grid gap-1">
|
||||
{label}
|
||||
<textarea
|
||||
rows={3}
|
||||
maxLength={4000}
|
||||
className="w-full min-w-0 rounded border p-2"
|
||||
aria-invalid={
|
||||
!!errors[`profile.fields.${key}`]
|
||||
}
|
||||
value={
|
||||
form.data.profile.fields[key] ?? ''
|
||||
}
|
||||
onChange={(e) =>
|
||||
set('fields', {
|
||||
...form.data.profile.fields,
|
||||
[key]: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
{errors[`profile.fields.${key}`] && (
|
||||
<span role="alert">
|
||||
{errors[`profile.fields.${key}`]}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
<label className="grid gap-1">
|
||||
Países de operação declarados
|
||||
<select
|
||||
multiple
|
||||
className="h-36 w-full rounded border p-2"
|
||||
value={form.data.profile.operation_countries}
|
||||
onChange={(e) =>
|
||||
set(
|
||||
'operation_countries',
|
||||
Array.from(
|
||||
e.target.selectedOptions,
|
||||
(o) => o.value,
|
||||
),
|
||||
)
|
||||
}
|
||||
>
|
||||
{data.countries.map((c) => (
|
||||
<option key={c.code} value={c.code}>
|
||||
{c.code} — {c.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<p className="text-sm">
|
||||
Estes países referem-se à operação. País mestre da
|
||||
entidade, país declarado no processo, origem,
|
||||
nacionalidade, residência, residência fiscal e
|
||||
cambial mantêm os seus cadastros e significados.
|
||||
Nenhuma classificação regulatória é inferida daqui.
|
||||
</p>
|
||||
<fieldset className="grid gap-3 md:grid-cols-2">
|
||||
<legend className="font-semibold">
|
||||
Atividades pretendidas, ainda sujeitas a
|
||||
enquadramento
|
||||
</legend>
|
||||
{Object.entries(data.activities).map(
|
||||
([key, label]) => (
|
||||
<label key={key} className="grid gap-1">
|
||||
{label}
|
||||
<select
|
||||
className="rounded border p-2"
|
||||
value={
|
||||
form.data.profile.activities[
|
||||
key
|
||||
] ?? 'unknown'
|
||||
}
|
||||
onChange={(e) =>
|
||||
set('activities', {
|
||||
...form.data.profile
|
||||
.activities,
|
||||
[key]: e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="unknown">
|
||||
Por determinar
|
||||
</option>
|
||||
<option value="no">
|
||||
Não previsto neste modelo
|
||||
</option>
|
||||
<option value="yes">
|
||||
Previsto neste modelo
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
),
|
||||
)}
|
||||
</fieldset>
|
||||
<label className="grid gap-1">
|
||||
Fundamento e limites da declaração de atividades
|
||||
<textarea
|
||||
rows={3}
|
||||
maxLength={3000}
|
||||
className="rounded border p-2"
|
||||
value={form.data.profile.activity_basis}
|
||||
onChange={(e) =>
|
||||
set('activity_basis', e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<fieldset className="grid gap-3">
|
||||
<legend className="font-semibold">
|
||||
Documentação por etapa e âmbito
|
||||
</legend>
|
||||
<p>
|
||||
Não é obrigatório anexar tudo para criar ou
|
||||
preparar a ideia. Selecione documentos já
|
||||
associados ao dossier; a associação não publica
|
||||
o ficheiro.
|
||||
</p>
|
||||
{data.documents.map((d) => (
|
||||
<label key={d.code} className="grid gap-1">
|
||||
{d.stage} · {d.label}
|
||||
<select
|
||||
className="w-full rounded border p-2"
|
||||
aria-invalid={
|
||||
!!errors[
|
||||
`profile.documents.${d.code}`
|
||||
]
|
||||
}
|
||||
value={
|
||||
form.data.profile.documents[
|
||||
d.code
|
||||
] ?? ''
|
||||
}
|
||||
onChange={(e) =>
|
||||
set('documents', {
|
||||
...form.data.profile.documents,
|
||||
[d.code]: e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
Ainda não associado
|
||||
</option>
|
||||
{documents.map((doc) => (
|
||||
<option
|
||||
key={doc.document_id}
|
||||
value={doc.document_id}
|
||||
>
|
||||
{doc.file_name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<span className="text-sm">{d.action}</span>
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
{canWrite && (
|
||||
<button
|
||||
type="submit"
|
||||
disabled={form.processing}
|
||||
className="rounded border px-4 py-2"
|
||||
>
|
||||
{form.processing
|
||||
? 'A guardar…'
|
||||
: 'Guardar caracterização incompleta'}
|
||||
</button>
|
||||
)}
|
||||
</fieldset>
|
||||
{form.recentlySuccessful && (
|
||||
<p role="status">
|
||||
Caracterização guardada. Continue a preparação nas
|
||||
etapas e ferramentas deste dossier.
|
||||
</p>
|
||||
)}
|
||||
{!canWrite && (
|
||||
<p>
|
||||
Consulta autorizada. A preparação destes campos cabe
|
||||
ao titular; a conferência independente usa os
|
||||
controlos de etapa existentes.
|
||||
</p>
|
||||
)}
|
||||
</form>
|
||||
<section
|
||||
aria-label="Aplicabilidade declarada Fintech"
|
||||
className="mt-5 space-y-3"
|
||||
>
|
||||
<h3 className="font-semibold">
|
||||
Aplicabilidade por atividade e ação
|
||||
</h3>
|
||||
<p>
|
||||
Quem prepara: promotor. Quem confere: responsável
|
||||
interno independente. Quem decide externamente: entidade
|
||||
competente identificada no ato, quando aplicável.
|
||||
</p>
|
||||
<ul className="space-y-3">
|
||||
{data.requirements.map((q) => (
|
||||
<li key={q.code} className="rounded border p-3">
|
||||
<p>
|
||||
{q.activity} · {status[q.state]}
|
||||
</p>
|
||||
<p className="text-sm">{q.basis}</p>
|
||||
<p className="text-sm">
|
||||
Disposição, versão, período, licença,
|
||||
capital, taxa e prazo específicos: por
|
||||
determinar. A preparação independente pode
|
||||
continuar.
|
||||
</p>
|
||||
<p className="text-sm">{q.limit}</p>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
<section
|
||||
className="mt-5 space-y-2"
|
||||
aria-label="Preparação operacional Fintech"
|
||||
>
|
||||
<h3 className="font-semibold">
|
||||
Recursos e preparação da operação
|
||||
</h3>
|
||||
<p>
|
||||
Registe investimento, capital próprio, financiamento
|
||||
assegurado, necessidade e pressupostos na ferramenta
|
||||
financeira existente. Dados desconhecidos permanecem
|
||||
indeterminados; não são zero.
|
||||
</p>
|
||||
{simulator && (
|
||||
<Link className="underline" href={simulator}>
|
||||
Preparar o orçamento e recuperar o resultado neste
|
||||
dossier
|
||||
</Link>
|
||||
)}
|
||||
<p>
|
||||
<a href="#S16" className="underline">
|
||||
S16 · Implementação
|
||||
</a>{' '}
|
||||
·{' '}
|
||||
<a href="#S17" className="underline">
|
||||
S17 · Testes e preparação operacional
|
||||
</a>{' '}
|
||||
·{' '}
|
||||
<a href="#S18" className="underline">
|
||||
S18 · Início de operação
|
||||
</a>{' '}
|
||||
·{' '}
|
||||
<a href="#S19" className="underline">
|
||||
S19 · Acompanhamento
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
Guardar um marco preparatório ou uma conferência interna
|
||||
não comprova autorização institucional. Use o ato
|
||||
externo, documento e âmbito quando existirem; não há
|
||||
integração automática com instituições.
|
||||
</p>
|
||||
</section>
|
||||
<section className="mt-4">
|
||||
<h3 className="font-semibold">
|
||||
Orientação preparatória existente
|
||||
</h3>
|
||||
<ul>
|
||||
{data.guidance.map((item) => (
|
||||
<li key={item.stage}>
|
||||
{item.stage}:{' '}
|
||||
{item.recommendations
|
||||
.map((r) => r.explanation)
|
||||
.join(' ')}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<p className="text-sm">
|
||||
Versão: {data.guidance_version}. As recomendações não
|
||||
são decisões externas e não criam outra sequência de
|
||||
etapas.
|
||||
</p>
|
||||
</section>
|
||||
<ul className="mt-4 text-sm">
|
||||
{data.limits.map((limit) => (
|
||||
<li key={limit}>{limit}</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,8 @@
|
||||
import {
|
||||
ClassificationEditor,
|
||||
type ClassificationOptions,
|
||||
type ClassificationRelation,
|
||||
} from './opportunity-classification';
|
||||
import { valueText } from '@/lib/value-text';
|
||||
import OpportunityParcelGeometry from './opportunity-parcel-geometry';
|
||||
import TerritoryGeometryPreview from './territory-geometry-preview';
|
||||
@@ -27,11 +32,15 @@ function resourceTerritory(resource?: Resource) {
|
||||
return typeof id === 'string' ? id : undefined;
|
||||
}
|
||||
export type CanonicalOptions = {
|
||||
classification?: ClassificationOptions;
|
||||
version: string;
|
||||
modularProfiles?: Record<string, string>;
|
||||
historyVersion?: string | null;
|
||||
schema: Schema;
|
||||
submissionTextLimits?: Record<string, { minLength?: number; maxLength?: number }>;
|
||||
submissionTextLimits?: Record<
|
||||
string,
|
||||
{ minLength?: number; maxLength?: number }
|
||||
>;
|
||||
definitions: Record<string, Schema>;
|
||||
contacts: { id: string; full_name: string }[];
|
||||
contactInvestors?: { id: string; legal_name: string }[];
|
||||
@@ -205,6 +214,7 @@ const labels: Record<string, string> = {
|
||||
environmental_social: 'Aspetos ambientais e sociais',
|
||||
risks: 'Riscos',
|
||||
relations: 'Relações',
|
||||
enterprise_size: 'Dimensão empresarial declarada (separada do setor)',
|
||||
amount: 'Montante',
|
||||
name: 'Nome',
|
||||
label: 'Designação',
|
||||
@@ -316,11 +326,19 @@ function Editor({
|
||||
schema = options.definitions[schema.$ref.split('/').pop()!] ?? schema;
|
||||
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
||||
const label = labels[name] ?? name.replaceAll('_', ' ');
|
||||
const parcelUnit = name === 'area_unit' && path.includes('land_rights.parcels.');
|
||||
const textLimits = path === 'canonical.demand_statement'
|
||||
? options.submissionTextLimits?.demand_statement
|
||||
: undefined;
|
||||
const descriptions = [errors[path] ? path + '-error' : '', parcelUnit ? path + '-help' : '', textLimits ? path + '-length-help' : ''].filter(Boolean).join(' ');
|
||||
const parcelUnit =
|
||||
name === 'area_unit' && path.includes('land_rights.parcels.');
|
||||
const textLimits =
|
||||
path === 'canonical.demand_statement'
|
||||
? options.submissionTextLimits?.demand_statement
|
||||
: undefined;
|
||||
const descriptions = [
|
||||
errors[path] ? path + '-error' : '',
|
||||
parcelUnit ? path + '-help' : '',
|
||||
textLimits ? path + '-length-help' : '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
const props = {
|
||||
id: path,
|
||||
'aria-invalid': !!errors[path],
|
||||
@@ -416,7 +434,12 @@ function Editor({
|
||||
.map((v) => (
|
||||
<option key={valueText(v)} value={valueText(v)}>
|
||||
{name === 'area_unit'
|
||||
? ({ sqm: 'Metros quadrados (m²)', ha: 'Hectares (ha)', sqkm: 'Quilómetros quadrados (km²)' }[valueText(v) as 'sqm' | 'ha' | 'sqkm'] ?? valueText(v))
|
||||
? ({
|
||||
sqm: 'Metros quadrados (m²)',
|
||||
ha: 'Hectares (ha)',
|
||||
sqkm: 'Quilómetros quadrados (km²)',
|
||||
}[valueText(v) as 'sqm' | 'ha' | 'sqkm'] ??
|
||||
valueText(v))
|
||||
: valueText(v).replaceAll('_', ' ')}
|
||||
</option>
|
||||
))}
|
||||
@@ -563,10 +586,11 @@ function Editor({
|
||||
{input}
|
||||
{textLimits && (
|
||||
<p id={path + '-length-help'} className="text-sm text-gray-600">
|
||||
Descreva a necessidade e a finalidade da oportunidade.
|
||||
Para submeter: {textLimits.minLength} a {textLimits.maxLength} caracteres.
|
||||
Texto atual: {Array.from(valueText(value ?? '').trim()).length} caracteres.
|
||||
Pode guardar o rascunho incompleto.
|
||||
Descreva a necessidade e a finalidade da oportunidade. Para
|
||||
submeter: {textLimits.minLength} a {textLimits.maxLength}{' '}
|
||||
caracteres. Texto atual:{' '}
|
||||
{Array.from(valueText(value ?? '').trim()).length}{' '}
|
||||
caracteres. Pode guardar o rascunho incompleto.
|
||||
</p>
|
||||
)}
|
||||
{parcelUnit && (
|
||||
@@ -636,6 +660,8 @@ export default function OpportunityCanonicalFields({
|
||||
'review_due_date',
|
||||
'images',
|
||||
'truth_declaration',
|
||||
'enterprise_size',
|
||||
'relations',
|
||||
];
|
||||
const specialized =
|
||||
category === 'real_estate'
|
||||
@@ -788,6 +814,55 @@ export default function OpportunityCanonicalFields({
|
||||
</p>
|
||||
)}
|
||||
{Array.from(new Set([...common, ...specialized])).map((key) => {
|
||||
if (key === 'relations' && options.classification) {
|
||||
const rows = (value.relations ??
|
||||
[]) as ClassificationRelation[];
|
||||
const legacySchema = options.definitions.relationCreate;
|
||||
return (
|
||||
<div key={key} className="space-y-4">
|
||||
<ClassificationEditor
|
||||
rows={rows}
|
||||
onChange={(rows) => set('relations', rows)}
|
||||
options={options.classification}
|
||||
documents={options.resources.documents ?? []}
|
||||
authorities={options.authorities}
|
||||
errors={errors}
|
||||
/>
|
||||
{rows.map((row, i) =>
|
||||
!row.classification ? (
|
||||
<Editor
|
||||
key={i}
|
||||
name={`Relação anterior ${i + 1}`}
|
||||
path={`canonical.relations.${i}`}
|
||||
schema={{
|
||||
...legacySchema,
|
||||
properties: Object.fromEntries(
|
||||
Object.entries(
|
||||
legacySchema.properties ??
|
||||
{},
|
||||
).filter(
|
||||
([k]) =>
|
||||
k !== 'classification',
|
||||
),
|
||||
),
|
||||
}}
|
||||
value={row}
|
||||
options={options}
|
||||
errors={errors}
|
||||
onChange={(v) =>
|
||||
set(
|
||||
'relations',
|
||||
rows.map((r, j) =>
|
||||
j === i ? v : r,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
) : null,
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (key === 'module_profile_version') {
|
||||
const current = valueText(value[key] ?? '');
|
||||
const version =
|
||||
|
||||
@@ -0,0 +1,917 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { router } from '@inertiajs/react';
|
||||
import { control, button } from '@/pages/management/shared';
|
||||
import { valueText } from '@/lib/value-text';
|
||||
|
||||
type Classification = {
|
||||
target_type: string;
|
||||
purpose: string;
|
||||
requested_state: string;
|
||||
disclosure: string;
|
||||
criteria?: string;
|
||||
justification?: string;
|
||||
source_reference?: string;
|
||||
citation?: string;
|
||||
authority_id?: string | null;
|
||||
document_id?: string | null;
|
||||
external_status?: string;
|
||||
external_act_reference?: string;
|
||||
production_stage?: string;
|
||||
valid_from?: string | null;
|
||||
valid_until?: string | null;
|
||||
};
|
||||
export type ClassificationRelation = {
|
||||
related_id: string;
|
||||
relation_type: string;
|
||||
classification?: Classification;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
export type ClassificationOptions = {
|
||||
dimensions: Record<string, string>;
|
||||
types: Record<string, string>;
|
||||
purposes: Record<string, string>;
|
||||
targets: Record<string, { id: string | number; label: string }[]>;
|
||||
externalStates: string[];
|
||||
};
|
||||
const typeLabels: Record<string, string> = {
|
||||
park: 'Parque industrial — organização produtiva',
|
||||
corridor: 'Corredor',
|
||||
location: 'Localização',
|
||||
cluster: 'Cluster',
|
||||
project: 'Projeto âncora',
|
||||
chain: 'Cadeia de valor',
|
||||
zone: 'Zona ou parque',
|
||||
sector: 'Setor',
|
||||
activity: 'Subsector ou atividade',
|
||||
};
|
||||
export const classificationStates: Record<string, string> = {
|
||||
draft: 'Rascunho',
|
||||
preliminary: 'Preliminar',
|
||||
in_validation: 'Em validação',
|
||||
confirmed: 'Confirmado',
|
||||
rejected: 'Rejeitado',
|
||||
archived: 'Arquivado',
|
||||
revoked: 'Revogado',
|
||||
};
|
||||
const externalLabels: Record<string, string> = {
|
||||
not_assessed: 'Não determinado',
|
||||
pending: 'Pendente',
|
||||
documented_granted: 'Ato de concessão documentado',
|
||||
documented_denied: 'Ato de recusa documentado',
|
||||
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.';
|
||||
|
||||
export function ClassificationEditor({
|
||||
rows,
|
||||
onChange,
|
||||
options,
|
||||
documents,
|
||||
authorities,
|
||||
errors = {},
|
||||
}: {
|
||||
rows: ClassificationRelation[];
|
||||
onChange: (rows: ClassificationRelation[]) => void;
|
||||
options: ClassificationOptions;
|
||||
documents: {
|
||||
id: string;
|
||||
payload: { title?: string };
|
||||
file?: { file_name: string };
|
||||
}[];
|
||||
authorities: { id: string; label_pt_mz: string }[];
|
||||
errors?: Record<string, string>;
|
||||
}) {
|
||||
const container = useRef<HTMLElement>(null);
|
||||
useEffect(() => {
|
||||
const key = Object.keys(errors).find((k) =>
|
||||
k.startsWith('canonical.relations.'),
|
||||
);
|
||||
const index = key?.match(/^canonical\.relations\.(\d+)/)?.[1];
|
||||
if (index)
|
||||
container.current
|
||||
?.querySelector<HTMLSelectElement>(
|
||||
`[data-association-index="${index}"]`,
|
||||
)
|
||||
?.focus();
|
||||
}, [errors]);
|
||||
const patch = (
|
||||
index: number,
|
||||
fields: Partial<Classification>,
|
||||
related?: string,
|
||||
) =>
|
||||
onChange(
|
||||
rows.map((row, i) =>
|
||||
i === index
|
||||
? {
|
||||
...row,
|
||||
related_id: related ?? row.related_id,
|
||||
classification: { ...row.classification!, ...fields },
|
||||
}
|
||||
: row,
|
||||
),
|
||||
);
|
||||
return (
|
||||
<section
|
||||
ref={container}
|
||||
className="space-y-4"
|
||||
aria-label="Classificação multidimensional"
|
||||
>
|
||||
<h3 className="font-semibold">Quatro dimensões da oportunidade</h3>
|
||||
<p>{help}</p>
|
||||
{Object.entries(options.dimensions).map(([dimension, label]) => (
|
||||
<fieldset
|
||||
key={dimension}
|
||||
className="min-w-0 space-y-3 rounded border p-3"
|
||||
>
|
||||
<legend>{label}</legend>
|
||||
{rows.map((row, index) =>
|
||||
row.classification &&
|
||||
options.types[row.classification.target_type] ===
|
||||
dimension ? (
|
||||
<fieldset
|
||||
key={index}
|
||||
className="min-w-0 space-y-2 rounded border p-3"
|
||||
>
|
||||
<legend>Associação {index + 1}</legend>
|
||||
<div className="grid min-w-0 gap-3 md:grid-cols-2">
|
||||
<label>
|
||||
Tipo
|
||||
<select
|
||||
className={control}
|
||||
value={
|
||||
row.classification.target_type
|
||||
}
|
||||
onChange={(e) =>
|
||||
patch(
|
||||
index,
|
||||
{
|
||||
target_type:
|
||||
e.target.value,
|
||||
},
|
||||
'',
|
||||
)
|
||||
}
|
||||
>
|
||||
{Object.entries(options.types)
|
||||
.filter(
|
||||
([, d]) => d === dimension,
|
||||
)
|
||||
.map(([kind]) => (
|
||||
<option
|
||||
key={kind}
|
||||
value={kind}
|
||||
>
|
||||
{typeLabels[kind]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Referência existente
|
||||
<select
|
||||
className={control}
|
||||
value={row.related_id}
|
||||
aria-label="Referência existente"
|
||||
data-association-index={index}
|
||||
aria-describedby={
|
||||
errors[
|
||||
`canonical.relations.${index}.related_id`
|
||||
]
|
||||
? `canonical.relations.${index}.related_id-error`
|
||||
: undefined
|
||||
}
|
||||
onChange={(e) =>
|
||||
patch(index, {}, e.target.value)
|
||||
}
|
||||
aria-invalid={
|
||||
!!errors[
|
||||
`canonical.relations.${index}.related_id`
|
||||
]
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
Selecionar referência
|
||||
</option>
|
||||
{(
|
||||
options.targets[
|
||||
row.classification
|
||||
.target_type
|
||||
] ?? []
|
||||
).map((t) => (
|
||||
<option
|
||||
key={t.id}
|
||||
value={String(t.id)}
|
||||
>
|
||||
{t.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{errors[
|
||||
`canonical.relations.${index}.related_id`
|
||||
] && (
|
||||
<span
|
||||
id={`canonical.relations.${index}.related_id-error`}
|
||||
role="alert"
|
||||
className="block text-red-800"
|
||||
>
|
||||
{
|
||||
errors[
|
||||
`canonical.relations.${index}.related_id`
|
||||
]
|
||||
}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
<label>
|
||||
Finalidade
|
||||
<select
|
||||
className={control}
|
||||
value={row.classification.purpose}
|
||||
onChange={(e) =>
|
||||
patch(index, {
|
||||
purpose: e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
Selecionar finalidade
|
||||
</option>
|
||||
{Object.entries(
|
||||
options.purposes,
|
||||
).map(([k, v]) => (
|
||||
<option key={k} value={k}>
|
||||
{v}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Estado solicitado
|
||||
<select
|
||||
className={control}
|
||||
value={
|
||||
row.classification
|
||||
.requested_state
|
||||
}
|
||||
onChange={(e) =>
|
||||
patch(index, {
|
||||
requested_state:
|
||||
e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
{[
|
||||
'draft',
|
||||
'preliminary',
|
||||
'in_validation',
|
||||
].map((s) => (
|
||||
<option key={s} value={s}>
|
||||
{classificationStates[s]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{(
|
||||
[
|
||||
'criteria',
|
||||
'justification',
|
||||
'source_reference',
|
||||
'citation',
|
||||
'external_act_reference',
|
||||
'production_stage',
|
||||
] as const
|
||||
).map((key) => (
|
||||
<label key={key}>
|
||||
{
|
||||
{
|
||||
criteria: 'Critérios',
|
||||
justification:
|
||||
'Justificação',
|
||||
source_reference:
|
||||
'Fonte identificada',
|
||||
citation:
|
||||
'Artigo, página ou referência',
|
||||
external_act_reference:
|
||||
'Referência do ato externo',
|
||||
production_stage:
|
||||
'Etapa produtiva documentada',
|
||||
}[key]
|
||||
}
|
||||
<textarea
|
||||
className={control}
|
||||
value={
|
||||
row.classification?.[key] ??
|
||||
''
|
||||
}
|
||||
onChange={(e) =>
|
||||
patch(index, {
|
||||
[key]: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
<label>
|
||||
Documento de suporte
|
||||
<select
|
||||
className={control}
|
||||
value={
|
||||
row.classification
|
||||
.document_id ?? ''
|
||||
}
|
||||
onChange={(e) =>
|
||||
patch(index, {
|
||||
document_id:
|
||||
e.target.value || null,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
Por associar, se aplicável
|
||||
</option>
|
||||
{documents.map((d) => (
|
||||
<option key={d.id} value={d.id}>
|
||||
{d.payload.title ??
|
||||
d.file?.file_name ??
|
||||
d.id}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Entidade competente
|
||||
<select
|
||||
className={control}
|
||||
value={
|
||||
row.classification
|
||||
.authority_id ?? ''
|
||||
}
|
||||
onChange={(e) =>
|
||||
patch(index, {
|
||||
authority_id:
|
||||
e.target.value || null,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
Por determinar
|
||||
</option>
|
||||
{authorities.map((a) => (
|
||||
<option key={a.id} value={a.id}>
|
||||
{a.label_pt_mz}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Estado do ato externo
|
||||
<select
|
||||
className={control}
|
||||
value={
|
||||
row.classification
|
||||
.external_status ??
|
||||
'not_assessed'
|
||||
}
|
||||
onChange={(e) =>
|
||||
patch(index, {
|
||||
external_status:
|
||||
e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
{options.externalStates.map((s) => (
|
||||
<option key={s} value={s}>
|
||||
{externalLabels[s]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Divulgação após publicação editorial
|
||||
<select
|
||||
className={control}
|
||||
value={
|
||||
row.classification.disclosure
|
||||
}
|
||||
onChange={(e) =>
|
||||
patch(index, {
|
||||
disclosure: e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="restricted">
|
||||
Reservada
|
||||
</option>
|
||||
<option value="public">
|
||||
Pública: referência, fonte e
|
||||
citação
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
{(
|
||||
['valid_from', 'valid_until'] as const
|
||||
).map((k) => (
|
||||
<label key={k}>
|
||||
{k === 'valid_from'
|
||||
? 'Válida desde'
|
||||
: 'Válida até'}
|
||||
<input
|
||||
className={control}
|
||||
type="date"
|
||||
value={
|
||||
row.classification?.[k] ??
|
||||
''
|
||||
}
|
||||
onChange={(e) =>
|
||||
patch(index, {
|
||||
[k]:
|
||||
e.target.value ||
|
||||
null,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
{Object.entries(errors)
|
||||
.filter(
|
||||
([key]) =>
|
||||
!key.endsWith('.related_id') &&
|
||||
key.startsWith(
|
||||
`canonical.relations.${index}.`,
|
||||
),
|
||||
)
|
||||
.map(([key, message]) => (
|
||||
<p
|
||||
key={key}
|
||||
id={`${key}-error`}
|
||||
role="alert"
|
||||
>
|
||||
{message}
|
||||
</p>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
onClick={() =>
|
||||
onChange(
|
||||
rows.filter((_, i) => i !== index),
|
||||
)
|
||||
}
|
||||
>
|
||||
Retirar esta associação do rascunho
|
||||
</button>
|
||||
</fieldset>
|
||||
) : null,
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
onClick={() => {
|
||||
const kind = Object.keys(options.types).find(
|
||||
(k) => options.types[k] === dimension,
|
||||
)!;
|
||||
onChange([
|
||||
...rows,
|
||||
{
|
||||
related_id: '',
|
||||
relation_type: 'classification',
|
||||
classification: {
|
||||
target_type: kind,
|
||||
purpose: '',
|
||||
requested_state: 'preliminary',
|
||||
disclosure: 'restricted',
|
||||
external_status: 'not_assessed',
|
||||
},
|
||||
},
|
||||
]);
|
||||
}}
|
||||
>
|
||||
Acrescentar relação — {label}
|
||||
</button>
|
||||
</fieldset>
|
||||
))}
|
||||
{rows.some((r) => !r.classification) && (
|
||||
<p>
|
||||
As {rows.filter((r) => !r.classification).length} relações
|
||||
anteriores sem classificação tipada permanecem guardadas. A
|
||||
ausência de metadados não revoga a sua aceitação.
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
type ReviewEvent = {
|
||||
state: string;
|
||||
at: string;
|
||||
reason: string;
|
||||
actor_id: number;
|
||||
version: number;
|
||||
};
|
||||
type ReviewRow = {
|
||||
previous_versions?: {
|
||||
metadata: { id: string; version: number };
|
||||
history: ReviewEvent[];
|
||||
}[];
|
||||
hash: string;
|
||||
dimension: string;
|
||||
state: string;
|
||||
can_review: boolean;
|
||||
relation: ClassificationRelation;
|
||||
history: {
|
||||
state: string;
|
||||
at: string;
|
||||
reason: string;
|
||||
actor_id: number;
|
||||
version: number;
|
||||
}[];
|
||||
};
|
||||
export function ClassificationReview({
|
||||
id,
|
||||
refreshToken,
|
||||
}: {
|
||||
id: number;
|
||||
refreshToken: string | null;
|
||||
}) {
|
||||
const [result, setResult] = useState<{
|
||||
etag: string;
|
||||
rows: ReviewRow[];
|
||||
duplicates?: { id: number; reference: string; reason: string }[];
|
||||
} | null>(null);
|
||||
const [error, setError] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [reason, setReason] = useState('');
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
fetch(`/minhas-oportunidades/${id}/classification`, {
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
.then(async (r) => {
|
||||
if (!r.ok)
|
||||
throw new Error(
|
||||
'Não foi possível recuperar as associações. Atualize a página; os dados guardados permanecem preservados.',
|
||||
);
|
||||
return r.json();
|
||||
})
|
||||
.then((data) => {
|
||||
if (active) setResult(data);
|
||||
})
|
||||
.catch((e) => {
|
||||
if (active) setError(String(e.message));
|
||||
});
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [id, refreshToken]);
|
||||
async function decide(row: ReviewRow, state: string) {
|
||||
setBusy(true);
|
||||
setError('');
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/minhas-oportunidades/${id}/classification/review`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'X-XSRF-TOKEN': decodeURIComponent(
|
||||
document.cookie
|
||||
.split('; ')
|
||||
.find((c) => c.startsWith('XSRF-TOKEN='))
|
||||
?.slice(11) ?? '',
|
||||
),
|
||||
},
|
||||
body: JSON.stringify({
|
||||
etag: result?.etag,
|
||||
hash: row.hash,
|
||||
state,
|
||||
reason,
|
||||
}),
|
||||
},
|
||||
);
|
||||
const data = await response.json();
|
||||
if (!response.ok)
|
||||
throw new Error(
|
||||
data.message ??
|
||||
'Decisão não gravada. Preserve o fundamento e atualize antes de repetir.',
|
||||
);
|
||||
setResult(data);
|
||||
router.reload({ only: ['etag', 'record', 'canonicalResponse'] });
|
||||
} catch (e) {
|
||||
setError(
|
||||
e instanceof Error ? e.message : 'Falha ao registar decisão.',
|
||||
);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<section
|
||||
className="min-w-0 space-y-3 rounded border p-4"
|
||||
aria-label="Confirmação das associações"
|
||||
>
|
||||
<h2 className="text-xl font-bold">Confirmação por associação</h2>
|
||||
<p>{help}</p>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
{!result && !error && <p role="status">A recuperar associações…</p>}
|
||||
{result?.rows.length === 0 && (
|
||||
<p>
|
||||
Sem associações tipadas guardadas. Os vínculos anteriores
|
||||
continuam no respetivo cadastro.
|
||||
</p>
|
||||
)}
|
||||
{result?.rows.some((r) => r.can_review) && (
|
||||
<label>
|
||||
Fundamento da decisão (mínimo 20 caracteres)
|
||||
<textarea
|
||||
className={control}
|
||||
value={reason}
|
||||
onChange={(e) => setReason(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
{result?.rows.map((row) => (
|
||||
<article
|
||||
key={row.hash}
|
||||
className="min-w-0 space-y-2 rounded border p-3"
|
||||
>
|
||||
<h3 className="font-semibold">
|
||||
{typeLabels[row.relation.classification!.target_type]} —{' '}
|
||||
{classificationStates[row.state]}
|
||||
</h3>
|
||||
<p className="break-words">
|
||||
Referência: {row.relation.related_id} ·{' '}
|
||||
{row.relation.classification!.source_reference ||
|
||||
'Fonte por indicar'}{' '}
|
||||
·{' '}
|
||||
{row.relation.classification!.citation ||
|
||||
'Citação por indicar'}
|
||||
</p>
|
||||
<p>
|
||||
Ato externo:{' '}
|
||||
{
|
||||
externalLabels[
|
||||
row.relation.classification!.external_status ??
|
||||
'not_assessed'
|
||||
]
|
||||
}
|
||||
. Disponibilidade de benefícios não inferida.
|
||||
</p>
|
||||
{row.can_review ? (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{[
|
||||
'in_validation',
|
||||
'confirmed',
|
||||
'rejected',
|
||||
'archived',
|
||||
'revoked',
|
||||
].map((state) => (
|
||||
<button
|
||||
key={state}
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={busy || reason.trim().length < 20}
|
||||
onClick={() => void decide(row, state)}
|
||||
>
|
||||
{classificationStates[state]}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p>
|
||||
Decisão indisponível nesta sessão: exige Validador
|
||||
no âmbito, responsabilidade correspondente, MFA e
|
||||
independência.
|
||||
</p>
|
||||
)}
|
||||
<p>
|
||||
{row.relation.classification!.criteria ||
|
||||
'Critérios por indicar'}{' '}
|
||||
·{' '}
|
||||
{row.relation.classification!.justification ||
|
||||
'Justificação por indicar'}
|
||||
</p>
|
||||
<details>
|
||||
<summary>Histórico desta versão</summary>
|
||||
{row.history.length ? (
|
||||
row.history.map((e) => (
|
||||
<p key={e.version}>
|
||||
{e.at} · v{e.version} ·{' '}
|
||||
{classificationStates[e.state]} ·
|
||||
responsável #{e.actor_id} · {e.reason}
|
||||
</p>
|
||||
))
|
||||
) : (
|
||||
<p>Sem decisão registada para este conteúdo.</p>
|
||||
)}
|
||||
</details>
|
||||
{!!row.previous_versions?.length && (
|
||||
<details>
|
||||
<summary>Versões anteriores preservadas</summary>
|
||||
{row.previous_versions.map((v, i) => (
|
||||
<div key={i}>
|
||||
<p>
|
||||
Identidade {v.metadata.id} · v
|
||||
{v.metadata.version}
|
||||
</p>
|
||||
{v.history.map((e) => (
|
||||
<p key={e.version}>
|
||||
{e.at} ·{' '}
|
||||
{classificationStates[e.state]} ·
|
||||
responsável #{e.actor_id} ·{' '}
|
||||
{e.reason}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</details>
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
{!!result?.duplicates?.length && (
|
||||
<aside>
|
||||
<h3>Possíveis duplicados — decisão pendente</h3>
|
||||
{result.duplicates.map((d) => (
|
||||
<p key={d.id}>
|
||||
{d.reference}: {d.reason}
|
||||
</p>
|
||||
))}
|
||||
</aside>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export type PublicClassification = {
|
||||
dimension: string;
|
||||
target_type: string;
|
||||
target_id: string;
|
||||
label: string;
|
||||
purpose: string;
|
||||
purpose_label?: string;
|
||||
state: string;
|
||||
source_reference?: string;
|
||||
citation?: string;
|
||||
external_status: string;
|
||||
production_stage?: string;
|
||||
};
|
||||
export function ClassificationSummary({
|
||||
rows,
|
||||
}: {
|
||||
rows: PublicClassification[];
|
||||
}) {
|
||||
return (
|
||||
<section
|
||||
className="space-y-4 rounded border p-4"
|
||||
aria-label="Quatro dimensões da oportunidade"
|
||||
>
|
||||
<h2 className="text-xl font-bold">
|
||||
Classificação multidimensional
|
||||
</h2>
|
||||
<p>{help}</p>
|
||||
{Object.entries({
|
||||
territory: 'Enquadramento territorial',
|
||||
production: 'Organização produtiva',
|
||||
regulation: 'Regime regulatório',
|
||||
activity: 'Atividade económica',
|
||||
}).map(([dimension, label]) => (
|
||||
<section key={dimension}>
|
||||
<h3 className="font-semibold">{label}</h3>
|
||||
{rows.filter((r) => r.dimension === dimension).length ? (
|
||||
rows
|
||||
.filter((r) => r.dimension === dimension)
|
||||
.map((r, i) => (
|
||||
<p key={i} className="break-words">
|
||||
{r.label} · {classificationStates[r.state]}{' '}
|
||||
· {r.purpose_label ?? r.purpose} ·{' '}
|
||||
{r.source_reference || 'Fonte por indicar'}{' '}
|
||||
{r.citation} {r.production_stage} · Ato
|
||||
externo: {externalLabels[r.external_status]}
|
||||
. Benefício ou capacidade disponível: não
|
||||
inferido.
|
||||
</p>
|
||||
))
|
||||
) : (
|
||||
<p>
|
||||
Sem informação tipada publicada nesta dimensão;
|
||||
consulte também as relações anteriores abaixo.
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
))}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function ClassificationFilters({
|
||||
options,
|
||||
authorities,
|
||||
categories,
|
||||
values,
|
||||
onChange,
|
||||
}: {
|
||||
options: ClassificationOptions;
|
||||
authorities: { id: string; label_pt_mz: string }[];
|
||||
categories: string[];
|
||||
values: Record<string, unknown>;
|
||||
onChange: (key: string, value: string) => void;
|
||||
}) {
|
||||
const selectors: {
|
||||
key: string;
|
||||
label: string;
|
||||
choices: [string, string][];
|
||||
}[] = [
|
||||
{
|
||||
key: 'association_type',
|
||||
label: 'Tipo de associação',
|
||||
choices: Object.keys(options.types).map((k) => [k, typeLabels[k]]),
|
||||
},
|
||||
{
|
||||
key: 'association_target',
|
||||
label: 'Referência da associação',
|
||||
choices: (
|
||||
options.targets[String(values.association_type)] ?? []
|
||||
).map((r) => [String(r.id), r.label]),
|
||||
},
|
||||
{
|
||||
key: 'association_purpose',
|
||||
label: 'Finalidade da associação',
|
||||
choices: Object.entries(options.purposes),
|
||||
},
|
||||
{
|
||||
key: 'association_state',
|
||||
label: 'Confirmação da associação',
|
||||
choices: [
|
||||
'draft',
|
||||
'preliminary',
|
||||
'in_validation',
|
||||
'confirmed',
|
||||
'rejected',
|
||||
].map((k) => [k, classificationStates[k]]),
|
||||
},
|
||||
{
|
||||
key: 'chain_id',
|
||||
label: 'Cadeia de valor',
|
||||
choices: (options.targets.chain ?? []).map((r) => [
|
||||
String(r.id),
|
||||
r.label,
|
||||
]),
|
||||
},
|
||||
{
|
||||
key: 'subsector_id',
|
||||
label: 'Subsector ou atividade publicada',
|
||||
choices: (options.targets.activity ?? []).map((r) => [
|
||||
String(r.id),
|
||||
r.label,
|
||||
]),
|
||||
},
|
||||
{
|
||||
key: 'authority_id',
|
||||
label: 'Entidade competente',
|
||||
choices: authorities.map((a) => [a.id, a.label_pt_mz]),
|
||||
},
|
||||
{
|
||||
key: 'category',
|
||||
label: 'Modalidade da oportunidade',
|
||||
choices: categories.map((c) => [c, c]),
|
||||
},
|
||||
{
|
||||
key: 'publication_state',
|
||||
label: 'Estado editorial público',
|
||||
choices: [['published', 'Publicado']],
|
||||
},
|
||||
];
|
||||
return (
|
||||
<fieldset className="min-w-0 space-y-3 rounded border p-3">
|
||||
<legend>Classificação multidimensional — filtros combinados</legend>
|
||||
<p>
|
||||
Os filtros combinam-se por «e». Tipo, referência e finalidade
|
||||
identificam a mesma associação; cadeia, atividade e entidade
|
||||
podem constar de outras associações da mesma oportunidade. A
|
||||
pesquisa inclui apenas publicações públicas. Os vínculos
|
||||
anteriores continuam nos filtros próprios.
|
||||
</p>
|
||||
<div className="grid min-w-0 gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{selectors.map((s) => (
|
||||
<label key={s.key}>
|
||||
{s.label}
|
||||
<select
|
||||
className={control}
|
||||
value={valueText(values[s.key] ?? '')}
|
||||
onChange={(e) => onChange(s.key, e.target.value)}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{s.choices.map(([k, label]) => (
|
||||
<option key={k} value={k}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
export type SectorEntryData = {
|
||||
articles: {
|
||||
title: string;
|
||||
href: string;
|
||||
image: { href: string; alt: string } | null;
|
||||
scope: string;
|
||||
}[];
|
||||
relations: {
|
||||
id: string;
|
||||
title: string;
|
||||
href: string;
|
||||
kind: string;
|
||||
basis: string;
|
||||
source: string | null;
|
||||
}[];
|
||||
locations: {
|
||||
opportunity_title: string;
|
||||
href: string;
|
||||
location: Record<string, unknown>;
|
||||
}[];
|
||||
start_href: string | null;
|
||||
register_href: string | null;
|
||||
start_notice: string | null;
|
||||
register_notice: string | null;
|
||||
specialization_href: string | null;
|
||||
content_notice: string | null;
|
||||
};
|
||||
export default function SectorEntry({ data }: { data: SectorEntryData }) {
|
||||
return (
|
||||
<section
|
||||
className="space-y-5"
|
||||
aria-label="Explorar e desenvolver negócios"
|
||||
>
|
||||
<p>
|
||||
Explore o setor, prepare uma ideia e apresente um negócio na
|
||||
modalidade adequada. Cada oportunidade tem promotor, objetivo e
|
||||
dados próprios.
|
||||
</p>
|
||||
<nav aria-label="Ações no setor" className="flex flex-wrap gap-3">
|
||||
{data.start_href ? (
|
||||
<Link
|
||||
className="rounded bg-emerald-800 px-4 py-3 text-white"
|
||||
href={data.start_href}
|
||||
>
|
||||
Iniciar ou continuar uma ideia neste setor
|
||||
</Link>
|
||||
) : (
|
||||
<p role="status">{data.start_notice}</p>
|
||||
)}
|
||||
{data.register_href ? (
|
||||
<Link
|
||||
className="rounded border px-4 py-3"
|
||||
href={data.register_href}
|
||||
>
|
||||
Cadastrar oportunidade — escolher modalidade
|
||||
</Link>
|
||||
) : (
|
||||
<p role="status">{data.register_notice}</p>
|
||||
)}
|
||||
</nav>
|
||||
<p>
|
||||
Projeto de investimento, parceria, venda de negócio e franquia
|
||||
seguem os formulários e workflows existentes. Autentique-se
|
||||
quando for necessário guardar ou cadastrar. O cadastro usa o
|
||||
perfil e a modalidade já autorizados; se ainda não tem perfil,
|
||||
pode preparar a ideia e pedir o perfil de promotor.
|
||||
</p>
|
||||
<h2 className="text-xl font-bold">
|
||||
Conteúdo e possibilidades de negócio
|
||||
</h2>
|
||||
{data.content_notice && <p>{data.content_notice}</p>}
|
||||
{!data.articles.length && (
|
||||
<p>
|
||||
Conteúdo educativo setorial ainda não disponível. Pode
|
||||
iniciar uma ideia e consultar oportunidades.
|
||||
</p>
|
||||
)}
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{data.articles.map((a) => (
|
||||
<article
|
||||
className="min-w-0 rounded border p-4"
|
||||
key={a.href}
|
||||
>
|
||||
{a.image && (
|
||||
<img
|
||||
className="mb-3 h-36 w-full object-cover"
|
||||
src={a.image.href}
|
||||
alt={a.image.alt}
|
||||
/>
|
||||
)}
|
||||
<Link className="font-semibold underline" href={a.href}>
|
||||
{a.title}
|
||||
</Link>
|
||||
<p>{a.scope}</p>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
{data.specialization_href && (
|
||||
<p>
|
||||
<Link className="underline" href={data.specialization_href}>
|
||||
Preparar um investimento Fintech
|
||||
</Link>{' '}
|
||||
— especialização entre tecnologia e serviços financeiros; o
|
||||
modelo concreto determina as dependências.
|
||||
</p>
|
||||
)}
|
||||
<h2 className="text-xl font-bold">
|
||||
Projetos âncora, clusters e território
|
||||
</h2>
|
||||
{data.relations.length ? (
|
||||
<ul>
|
||||
{data.relations.map((r) => (
|
||||
<li className="mb-3" key={r.id}>
|
||||
<Link className="underline" href={r.href}>
|
||||
{r.title}
|
||||
</Link>
|
||||
<p>{r.basis}</p>
|
||||
{r.source && (
|
||||
<p className="text-sm break-words">
|
||||
Fonte: {r.source}
|
||||
</p>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p>
|
||||
Sem fichas publicadas com associação cadastrada às
|
||||
oportunidades públicas deste setor. A ausência de ligação
|
||||
não impede a preparação da ideia.
|
||||
</p>
|
||||
)}
|
||||
{!!data.locations.length && (
|
||||
<ul>
|
||||
{data.locations.map((l, i) => (
|
||||
<li key={i}>
|
||||
<Link className="underline" href={l.href}>
|
||||
{l.opportunity_title}
|
||||
</Link>
|
||||
:{' '}
|
||||
{String(
|
||||
l.location.name ??
|
||||
'Consultar localização e fonte na oportunidade',
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
<p>
|
||||
<Link className="underline" href="/carteira">
|
||||
Explorar projetos, corredores e clusters
|
||||
</Link>{' '}
|
||||
·{' '}
|
||||
<Link className="underline" href="/zonas">
|
||||
Consultar localizações
|
||||
</Link>{' '}
|
||||
·{' '}
|
||||
<Link className="underline" href="/parcerias">
|
||||
Explorar parceiros e propostas
|
||||
</Link>
|
||||
</p>
|
||||
<p>
|
||||
<Link className="underline" href="/perfil/promotor">
|
||||
Consultar ou pedir perfil de promotor
|
||||
</Link>
|
||||
</p>
|
||||
<p>
|
||||
As ligações acima representam cadastros existentes. Menções em
|
||||
artigos não demonstram implantação, disponibilidade de terreno
|
||||
ou parceria. Relações e parceiros específicos por confirmar
|
||||
permanecem identificados nas fichas.
|
||||
</p>
|
||||
<p>
|
||||
Ao guardar a ideia, continue nas cinco fases e 19 etapas e
|
||||
prepare o apoio no mesmo dossier, com documentos e ferramentas
|
||||
contextualizados.
|
||||
</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user