@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
import { useRef, useState } from 'react';
|
||||
import { Frame, input, button, card } from './shared';
|
||||
import { ClassificationEditor, ClassificationSummary, classificationStates, type ClassificationRelation, type ClassificationOptions, type PublicClassification } from '@/components/opportunity-classification';
|
||||
|
||||
type ReviewRow = { hash: string; relation: ClassificationRelation; state: string; dimension: string; can_review: boolean; history: { state: string; at: string; reason: string }[] };
|
||||
type Supplement = { id: string; title: string; status: string; version_no: number; rows: ReviewRow[]; publication: PublicClassification[]; preview: PublicClassification[]; publication_version: number | null; can_prepare: boolean; can_disclose: boolean; options: ClassificationOptions; authorities: { id: string; label_pt_mz: string }[]; documents: { id: string; payload: { title?: string }; file: { file_name: string } }[] };
|
||||
|
||||
export default function BusinessClassification({ supplement }: { supplement: Supplement }) {
|
||||
const [current, setCurrent] = useState(supplement);
|
||||
const [rows, setRows] = useState(supplement.rows.map((r) => r.relation));
|
||||
const [reason, setReason] = useState('');
|
||||
const [error, setError] = useState('');
|
||||
const [errors, setErrors] = useState<Record<string, string>>({});
|
||||
const [message, setMessage] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [preview, setPreview] = useState(false);
|
||||
const alert = useRef<HTMLDivElement>(null);
|
||||
const dirty = JSON.stringify(rows) !== JSON.stringify(current.rows.map((r) => r.relation));
|
||||
async function act(action: string, fields: Record<string, unknown> = {}) {
|
||||
setBusy(true); setError(''); setErrors({}); setMessage('');
|
||||
try {
|
||||
const token = decodeURIComponent(document.cookie.split('; ').find((v) => v.startsWith('XSRF-TOKEN='))?.slice(11) ?? '');
|
||||
const response = await fetch(`/api/v1/existing-business/listings/${current.id}/classification`, { method: 'POST', credentials: 'same-origin', headers: { Accept: 'application/json', 'Content-Type': 'application/json', 'X-XSRF-TOKEN': token }, body: JSON.stringify({ action, version_no: current.version_no, reason, ...fields }) });
|
||||
const result = await response.json();
|
||||
if (!response.ok) {
|
||||
const details = Object.fromEntries(Object.entries(result.errors ?? {}).map(([key, value]) => [key, (value as string[]).join(' ')]));
|
||||
setErrors(details);
|
||||
throw new Error(Object.values(details)[0] || result.message || 'Não foi possível concluir. Os valores preparados permanecem no formulário.');
|
||||
}
|
||||
setCurrent(result.supplement); setRows(result.supplement.rows.map((r: ReviewRow) => r.relation)); setPreview(false);
|
||||
setMessage(action === 'prepare' ? 'Classificação guardada e recuperada. A publicação anterior mantém-se.' : action === 'review' ? 'Decisão registada. A divulgação continua separada.' : action === 'withdraw' ? 'Projeção da classificação retirada; anúncio preservado.' : 'Nova fotografia da classificação divulgada; anúncio preservado.');
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Não foi possível concluir. Preserve os valores e atualize a página.');
|
||||
requestAnimationFrame(() => alert.current?.focus());
|
||||
} finally { setBusy(false); }
|
||||
}
|
||||
const previewRows = current.preview;
|
||||
return <Frame title="Classificação do anúncio">
|
||||
<div className="mx-auto max-w-5xl space-y-5">
|
||||
<Link className="underline" href={`/investidor/negocios/${current.id}`}>Voltar ao mesmo anúncio</Link>
|
||||
<h1 className="text-2xl font-bold">{current.title}</h1>
|
||||
<p>Anúncio {current.status === 'published' ? 'publicado' : 'em preparação'} · versão {current.version_no}</p>
|
||||
<p>Este suplemento altera apenas a classificação. Conteúdo, confidencialidade e workflow do anúncio mantêm-se. Guardar ou confirmar uma relação não a divulga.</p>
|
||||
{error && <div ref={alert} tabIndex={-1} role="alert" className="rounded border border-red-600 p-3">{error}</div>}
|
||||
{message && <p role="status">{message}</p>}
|
||||
{current.can_prepare && <section className={card}>
|
||||
<ClassificationEditor rows={rows} onChange={setRows} options={current.options} documents={current.documents} authorities={current.authorities} errors={errors} />
|
||||
</section>}
|
||||
<label className="grid gap-1">Fundamento da ação <textarea className={input} value={reason} onChange={(e) => setReason(e.target.value)} minLength={20} maxLength={1000} /></label>
|
||||
<p className="text-sm">Indique o fundamento da operação, com pelo menos 20 caracteres. A nota permanece privada.</p>
|
||||
{current.can_prepare && <button className={button} disabled={busy} onClick={() => void act('prepare', { rows })}>Guardar classificação privada</button>}
|
||||
<section className="space-y-4" aria-label="Decisões por relação">
|
||||
<h2 className="text-xl font-bold">Relações guardadas e decisões</h2>
|
||||
{!current.rows.length && <p>Ainda não existem relações guardadas.</p>}
|
||||
{current.rows.map((r) => <article key={r.hash} className={card}>
|
||||
<h3 className="font-bold">{current.options.targets[r.relation.classification!.target_type]?.find((t) => String(t.id) === r.relation.related_id)?.label ?? 'Referência indisponível'}</h3>
|
||||
<p>{current.options.dimensions[r.dimension]} · {current.options.purposes[r.relation.classification!.purpose]} · {classificationStates[r.state]}</p>
|
||||
<p>Fonte: {r.relation.classification!.source_reference || 'Por indicar'} · {r.relation.classification!.citation || 'Citação por indicar'}</p>
|
||||
<p>Fundamento: {r.relation.classification!.justification || 'Por indicar'}</p>
|
||||
{r.can_review ? <div className="flex flex-wrap gap-2">{['confirmed', 'in_validation', 'rejected', 'revoked', 'archived'].map((state) => <button key={state} className={button} disabled={busy || dirty} onClick={() => void act('review', { hash: r.hash, state })}>{classificationStates[state]}</button>)}</div> : <p>Decisão indisponível nesta sessão: requer Validador independente, âmbito, responsabilidade e MFA aplicáveis.</p>}
|
||||
{!!r.history.length && <details><summary>Histórico de decisões</summary><ul>{r.history.map((h, i) => <li key={i}>{h.at} · {classificationStates[h.state]} · {h.reason}</li>)}</ul></details>}
|
||||
</article>)}
|
||||
</section>
|
||||
<section className={card} aria-label="Fotografia pública atual">
|
||||
<h2 className="text-xl font-bold">Fotografia pública atual</h2>
|
||||
<p>{current.publication_version ? `Divulgada na versão ${current.publication_version}.` : 'Sem classificação divulgada; o teaser anterior mantém-se.'}</p>
|
||||
<ClassificationSummary rows={current.publication} />
|
||||
</section>
|
||||
{current.can_disclose && <section className={`${card} space-y-3`}>
|
||||
<h2 className="text-xl font-bold">Divulgação expressa da classificação</h2>
|
||||
<p>Apenas as relações guardadas com intenção de divulgação pública integram a fotografia. Notas, contactos, critérios privados e ficheiros de suporte permanecem privados.</p>
|
||||
<button className={button} disabled={busy || dirty} onClick={() => setPreview(!preview)}>Conferir nova fotografia pública</button>
|
||||
{preview && <div><ClassificationSummary rows={previewRows} /><button className={button} disabled={busy || dirty} onClick={() => void act('disclose')}>Divulgar esta classificação</button></div>}
|
||||
<button className={button} disabled={busy} onClick={() => void act('withdraw')}>Retirar apenas a classificação pública</button>
|
||||
</section>}
|
||||
</div>
|
||||
</Frame>;
|
||||
}
|
||||
@@ -6,8 +6,10 @@ import {
|
||||
type TerritoryOption,
|
||||
} from '@/components/investment-territory';
|
||||
import { businessModalities } from './business-types';
|
||||
import { ClassificationSummary, classificationStates, type PublicClassification, type ClassificationOptions } from '@/components/opportunity-classification';
|
||||
|
||||
type PublicBusiness = {
|
||||
multidimensional?: PublicClassification[];
|
||||
id: string;
|
||||
slug: string;
|
||||
title: string;
|
||||
@@ -34,7 +36,10 @@ type Props = {
|
||||
};
|
||||
meta?: { links?: PaginationLink[]; total?: number };
|
||||
};
|
||||
classificationOptions?: ClassificationOptions;
|
||||
authorities?: { id: string; label_pt_mz: string }[];
|
||||
filters: {
|
||||
[key: string]: string | undefined;
|
||||
q?: string;
|
||||
modality?: string;
|
||||
province_id?: string;
|
||||
@@ -49,7 +54,10 @@ export default function BusinessMarketplace({
|
||||
results,
|
||||
filters,
|
||||
territorySelection = [],
|
||||
classificationOptions,
|
||||
authorities = [],
|
||||
}: Props) {
|
||||
const [classification, setClassification] = useState<Record<string, string>>(() => Object.fromEntries(['sector', 'association_type', 'association_target', 'association_purpose', 'association_state', 'chain_id', 'authority_id', 'subsector_id'].map((key) => [key, filters[key] ?? ''])));
|
||||
const [query, setQuery] = useState(filters.q ?? '');
|
||||
const [modality, setModality] = useState(filters.modality ?? '');
|
||||
const [territory, setTerritory] = useState<Record<string, string>>({
|
||||
@@ -62,6 +70,7 @@ export default function BusinessMarketplace({
|
||||
...(query ? { q: query } : {}),
|
||||
...(modality ? { modality } : {}),
|
||||
...territory,
|
||||
...classification,
|
||||
}).toString();
|
||||
const paginationLinks =
|
||||
results.meta?.links ??
|
||||
@@ -82,6 +91,7 @@ export default function BusinessMarketplace({
|
||||
q: query || undefined,
|
||||
modality: modality || undefined,
|
||||
...territory,
|
||||
...classification,
|
||||
},
|
||||
{ preserveState: true, preserveScroll: true },
|
||||
);
|
||||
@@ -125,6 +135,22 @@ export default function BusinessMarketplace({
|
||||
})
|
||||
}
|
||||
/>
|
||||
{classificationOptions && <fieldset className="w-full rounded border p-3">
|
||||
<legend>Classificação multidimensional — filtros combinados</legend>
|
||||
<p>Critérios diferentes combinam-se por «e». Tipo, referência, finalidade e estado têm de corresponder à mesma relação pública. O setor principal mantém o seu significado.</p>
|
||||
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{([
|
||||
['sector', 'Setor principal do anúncio', classificationOptions.targets.sector ?? []],
|
||||
['association_type', 'Tipo de associação', Object.keys(classificationOptions.types).map((id) => ({ id, label: ({ corridor: 'Corredor', location: 'Localização', cluster: 'Cluster', project: 'Projeto âncora', chain: 'Cadeia de valor', park: 'Parque industrial', zone: 'Regime de zona', sector: 'Setor associado', activity: 'Subsector ou atividade' } as Record<string, string>)[id] ?? id }))],
|
||||
['association_target', 'Referência da associação', classificationOptions.targets[classification.association_type] ?? []],
|
||||
['association_purpose', 'Finalidade', Object.entries(classificationOptions.purposes).map(([id, label]) => ({ id, label }))],
|
||||
['association_state', 'Estado da associação', Object.entries(classificationStates).filter(([id]) => !['archived', 'revoked'].includes(id)).map(([id, label]) => ({ id, label }))],
|
||||
['chain_id', 'Cadeia de valor', classificationOptions.targets.chain ?? []],
|
||||
['subsector_id', 'Subsector ou atividade', classificationOptions.targets.activity ?? []],
|
||||
['authority_id', 'Entidade competente', authorities.map((a) => ({ id: a.id, label: a.label_pt_mz }))],
|
||||
] as [string, string, { id: string | number; label: string }[]][]).map(([key, label, options]) => <label key={key} className="grid gap-1"><span>{label}</span><select className={input} value={classification[key]} onChange={(e) => setClassification((old) => ({ ...old, [key]: e.target.value, ...(key === 'association_type' ? { association_target: '' } : {}) }))}><option value="">Todos</option>{options.map((o) => <option key={o.id} value={String(o.id)}>{o.label}</option>)}</select></label>)}
|
||||
</div>
|
||||
</fieldset>}
|
||||
<button className={button}>Pesquisar</button>
|
||||
</form>
|
||||
<p role="status">
|
||||
@@ -166,6 +192,7 @@ export default function BusinessMarketplace({
|
||||
{record.amount_max ?? '—'} {record.currency}
|
||||
</p>
|
||||
)}
|
||||
{!!record.multidimensional?.length && <ClassificationSummary rows={record.multidimensional} />}
|
||||
{record.objective && (
|
||||
<p className="mt-3 line-clamp-3">
|
||||
{record.objective}
|
||||
|
||||
@@ -2,8 +2,10 @@ import { Link } from '@inertiajs/react';
|
||||
import { Frame, button, card } from './shared';
|
||||
import { businessModalities } from './business-types';
|
||||
import PartnershipSourceLinks from '@/components/partnership-source-links';
|
||||
import { ClassificationSummary, type PublicClassification } from '@/components/opportunity-classification';
|
||||
|
||||
type Business = {
|
||||
multidimensional?: PublicClassification[];
|
||||
id: string;
|
||||
slug: string;
|
||||
title: string;
|
||||
@@ -37,6 +39,7 @@ export default function BusinessOpportunity({
|
||||
Voltar às oportunidades
|
||||
</Link>
|
||||
<section className={`${card} space-y-4`}>
|
||||
{!!record.multidimensional?.length && <ClassificationSummary rows={record.multidimensional} />}
|
||||
<p>{businessModalities[record.modality] ?? record.modality}</p>
|
||||
<p>
|
||||
{[record.sector?.name, record.stage, record.activity_code]
|
||||
|
||||
@@ -533,6 +533,7 @@ export default function BusinessWizard({
|
||||
)}
|
||||
>
|
||||
<div lang={english ? 'en' : 'pt'} className="space-y-5">
|
||||
<a className="underline" href={`/investidor/negocios/${record.id}/classificacao`}>{t('Classificação multidimensional deste anúncio', 'Multidimensional classification of this listing')}</a>
|
||||
<button
|
||||
type="button"
|
||||
className="underline"
|
||||
|
||||
@@ -112,6 +112,7 @@ function Editor({
|
||||
};
|
||||
return (
|
||||
<Frame title={record.payload.title}>
|
||||
<p><Link className="underline" href={`/investidor/negocios/${record.id}/classificacao`}>Classificação multidimensional deste anúncio</Link></p>
|
||||
<Link
|
||||
className="underline"
|
||||
href={owner ? '/investidor/negocios' : '/management/negocios'}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ClassificationFilters } from '@/components/opportunity-classification';
|
||||
import { Link, router, useForm, usePage } from '@inertiajs/react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import Map from '@/components/interactive-investment-map';
|
||||
@@ -56,6 +57,15 @@ export default function Catalogue({
|
||||
}) {
|
||||
const { auth } = usePage<{ auth: { user: unknown } }>().props;
|
||||
const form = useForm({
|
||||
association_type: String(filters.association_type ?? ''),
|
||||
association_target: String(filters.association_target ?? ''),
|
||||
association_purpose: String(filters.association_purpose ?? ''),
|
||||
association_state: String(filters.association_state ?? ''),
|
||||
chain_id: String(filters.chain_id ?? ''),
|
||||
subsector_id: String(filters.subsector_id ?? ''),
|
||||
authority_id: String(filters.authority_id ?? ''),
|
||||
category: String(filters.category ?? ''),
|
||||
publication_state: String(filters.publication_state ?? ''),
|
||||
q: String(filters.q ?? ''),
|
||||
dimension: String(filters.dimension ?? ''),
|
||||
view: String(filters.view ?? 'grid'),
|
||||
@@ -326,6 +336,23 @@ export default function Catalogue({
|
||||
form.get(catalogueUrl, { preserveState: true });
|
||||
}}
|
||||
>
|
||||
{references.classification && (
|
||||
<ClassificationFilters
|
||||
options={references.classification}
|
||||
authorities={references.authorities ?? []}
|
||||
categories={references.categories ?? []}
|
||||
values={form.data}
|
||||
onChange={(key, value) =>
|
||||
form.setData((d) => ({
|
||||
...d,
|
||||
[key]: value,
|
||||
...(key === 'association_type'
|
||||
? { association_target: '' }
|
||||
: {}),
|
||||
}))
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<section
|
||||
aria-label="Localização da oportunidade"
|
||||
className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4"
|
||||
@@ -529,7 +556,9 @@ export default function Catalogue({
|
||||
>
|
||||
<option value="">Todos os níveis</option>
|
||||
{(references.maturityCatalogue
|
||||
? Object.values(references.maturityCatalogue.stages)
|
||||
? Object.values(
|
||||
references.maturityCatalogue.stages,
|
||||
)
|
||||
: MATURITY_LEVELS
|
||||
).map((label, index) => (
|
||||
<option key={index + 1} value={index + 1}>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ClassificationSummary } from '@/components/opportunity-classification';
|
||||
import { Link, router, usePage } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import InvestmentMapPanel from '@/components/investment-map-panel';
|
||||
@@ -51,6 +52,7 @@ export default function Detail({
|
||||
</p>
|
||||
)}
|
||||
<p className="text-xl">{r.summary}</p>
|
||||
<ClassificationSummary rows={c.classification ?? []} />
|
||||
<TerritorialSources sources={c.source_evidence} />
|
||||
<section className={card + ' space-y-3'}>
|
||||
<h2 className="text-xl font-bold">
|
||||
|
||||
@@ -23,6 +23,9 @@ export type Entity = {
|
||||
geography?: StructureGeography | null;
|
||||
};
|
||||
export type References = {
|
||||
classification?: import('@/components/opportunity-classification').ClassificationOptions;
|
||||
authorities?: { id: string; label_pt_mz: string }[];
|
||||
categories?: string[];
|
||||
maturityCatalogue?: {
|
||||
version: string;
|
||||
stages: Record<string, string>;
|
||||
@@ -58,6 +61,7 @@ export type Opportunity = {
|
||||
last_validated_at?: string | null;
|
||||
};
|
||||
export type Context = {
|
||||
classification?: import('@/components/opportunity-classification').PublicClassification[];
|
||||
source_evidence?: TerritorialSourceEvidence[];
|
||||
opportunity_locations?: DocumentedLocation[];
|
||||
primary_territory_path?: {
|
||||
|
||||
@@ -13,9 +13,11 @@ export type InvestmentContext = {
|
||||
export default function InvestmentContexts({
|
||||
contexts,
|
||||
contentSource,
|
||||
sectorSource,
|
||||
}: {
|
||||
contexts: InvestmentContext[];
|
||||
contentSource?: LegacyArticle;
|
||||
sectorSource?: { id: number; name: string; slug: string; href: string };
|
||||
}) {
|
||||
const [key] = useState(() => createOperationKey());
|
||||
const form = useForm({
|
||||
@@ -23,11 +25,22 @@ export default function InvestmentContexts({
|
||||
client_key: key,
|
||||
reuse_consent: false,
|
||||
content_resource_id: contentSource?.id,
|
||||
sector_slug: sectorSource?.slug,
|
||||
});
|
||||
return (
|
||||
<main className="mx-auto max-w-5xl space-y-6 p-4 md:p-8">
|
||||
<Head title="Os meus investimentos" />
|
||||
<h1 className="text-2xl font-semibold">Os meus investimentos</h1>
|
||||
{sectorSource && (
|
||||
<p>
|
||||
Preparar uma ideia em{' '}
|
||||
<Link className="underline" href={sectorSource.href}>
|
||||
{sectorSource.name}
|
||||
</Link>
|
||||
. O setor será recuperado no dossier, mesmo sem oportunidade
|
||||
publicada.
|
||||
</p>
|
||||
)}
|
||||
{contentSource && (
|
||||
<p>
|
||||
Preparar a partir de{' '}
|
||||
@@ -54,6 +67,23 @@ export default function InvestmentContexts({
|
||||
Guardado em{' '}
|
||||
{new Date(item.updated_at).toLocaleString('pt-MZ')}
|
||||
</p>
|
||||
{sectorSource && (
|
||||
<button
|
||||
type="button"
|
||||
className="mt-3 rounded border p-2"
|
||||
onClick={() =>
|
||||
router.post(
|
||||
`/investimentos/${item.id}/sectores`,
|
||||
{
|
||||
version: item.version,
|
||||
sector_slug: sectorSource.slug,
|
||||
},
|
||||
)
|
||||
}
|
||||
>
|
||||
Continuar neste dossier com o setor
|
||||
</button>
|
||||
)}
|
||||
{contentSource && (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import FintechInvestment, {
|
||||
type FintechView,
|
||||
} from '@/components/fintech-investment';
|
||||
import { createOperationKey } from '@/lib/operation-key';
|
||||
import { Head, Link, router, useForm, usePage } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
@@ -21,6 +24,8 @@ type Step = {
|
||||
source_paragraph: number;
|
||||
};
|
||||
type Path = {
|
||||
fintech: FintechView | null;
|
||||
sector_contexts: { id: number; name: string; slug: string; href: string }[];
|
||||
case: { id: string; title: string; version: number; closed: boolean };
|
||||
phases: Record<string, string>;
|
||||
steps: Step[];
|
||||
@@ -363,6 +368,40 @@ export default function InvestmentPath(path: Path) {
|
||||
Os meus investimentos
|
||||
</Link>
|
||||
<h1 className="text-2xl font-semibold">{path.case.title}</h1>
|
||||
{!!path.sector_contexts?.length && (
|
||||
<section className="rounded border p-4">
|
||||
<h2 className="text-lg font-semibold">Contexto setorial</h2>
|
||||
<ul>
|
||||
{path.sector_contexts.map((s) => (
|
||||
<li key={s.id}>
|
||||
<Link className="underline" href={s.href}>
|
||||
{s.name}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<p>
|
||||
Preparação privada nas mesmas cinco fases e 19 etapas; a
|
||||
escolha do setor não publica uma oportunidade.
|
||||
</p>
|
||||
</section>
|
||||
)}
|
||||
{path.fintech && (
|
||||
<FintechInvestment
|
||||
data={path.fintech}
|
||||
caseId={path.case.id}
|
||||
version={path.case.version}
|
||||
canWrite={path.canWrite}
|
||||
documents={path.documents}
|
||||
simulator={path.tools.simulator}
|
||||
fromArticle={
|
||||
path.content_sources.some(
|
||||
(source) => source.return_href === '/tech-fintech',
|
||||
) ||
|
||||
path.sector_contexts.some((s) => s.slug === 'fintech')
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{!!path.content_sources?.length && (
|
||||
<section
|
||||
className="space-y-2 rounded-xl border p-4"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ClassificationReview } from '@/components/opportunity-classification';
|
||||
import { createOperationKey } from '@/lib/operation-key';
|
||||
import { valueText } from '@/lib/value-text';
|
||||
import OpportunityProfileActions from '@/components/opportunity-profile-actions';
|
||||
@@ -221,9 +222,16 @@ export default function OpportunityDraft({
|
||||
);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
requestAnimationFrame(() =>
|
||||
document.getElementById('opportunity-result')?.focus(),
|
||||
);
|
||||
requestAnimationFrame(() => {
|
||||
const invalidAssociation =
|
||||
document.querySelector<HTMLSelectElement>(
|
||||
'[data-association-index][aria-invalid="true"]',
|
||||
);
|
||||
(
|
||||
invalidAssociation ??
|
||||
document.getElementById('opportunity-result')
|
||||
)?.focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
return (
|
||||
@@ -273,6 +281,9 @@ export default function OpportunityDraft({
|
||||
</p>
|
||||
</section>
|
||||
)}
|
||||
{profileMode && record && (
|
||||
<ClassificationReview id={record.id} refreshToken={token} />
|
||||
)}
|
||||
{profileMode && record && readOnly && canEditDraft && (
|
||||
<Link
|
||||
className="block underline"
|
||||
@@ -876,10 +887,10 @@ export default function OpportunityDraft({
|
||||
setData((prior) => ({
|
||||
...prior,
|
||||
canonical: {
|
||||
...((prior.canonical as Record<
|
||||
...(prior.canonical as Record<
|
||||
string,
|
||||
unknown
|
||||
>) ?? {}),
|
||||
>),
|
||||
internal_contact_id: contact.id,
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -237,6 +237,14 @@ export default function LegacySector({
|
||||
<h2 id="opportunities-title" className="text-2xl font-semibold">
|
||||
Oportunidades publicadas no setor
|
||||
</h2>
|
||||
{article.sector && (
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/sectores/${article.sector.slug}`}
|
||||
>
|
||||
Explorar negócios e ações neste setor
|
||||
</Link>
|
||||
)}
|
||||
<p>
|
||||
Cadastros independentes do artigo, com a sua própria autoria
|
||||
e situação de publicação.
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ProvinceSelect } from '@/components/investment-territory';
|
||||
import { SimulationForm } from '@/components/simulation-form';
|
||||
import { InvestmentRoadmap } from '@/components/investment-roadmap';
|
||||
import { JourneyDocumentResources } from '@/components/journey-document-resources';
|
||||
import SectorEntry, { type SectorEntryData } from '@/components/sector-entry';
|
||||
import CountrySelect, { type Country } from '@/components/country-select';
|
||||
|
||||
const input =
|
||||
@@ -97,6 +98,7 @@ type Page<T> = {
|
||||
total: number;
|
||||
};
|
||||
type Props = {
|
||||
sectorEntry?: SectorEntryData;
|
||||
countries?: Country[];
|
||||
section: string;
|
||||
filters?: Record<string, string | string[]>;
|
||||
@@ -586,6 +588,7 @@ export default function Services(p: Props) {
|
||||
p.sector.short_description ||
|
||||
'Descrição sectorial em preparação.'}
|
||||
</p>
|
||||
{p.sectorEntry && <SectorEntry data={p.sectorEntry} />}
|
||||
<h2 className="text-xl font-bold">
|
||||
Oportunidades no sector
|
||||
</h2>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<!doctype html>
|
||||
<html lang="pt"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Criação de oportunidade indisponível — InvesteMoz</title>
|
||||
<style>body{font-family:system-ui,sans-serif;line-height:1.6;margin:0;background:#f7faf9;color:#19352d}main{max-width:46rem;margin:8vh auto;padding:2rem;background:white;border:1px solid #dce7e2;border-radius:.6rem}h1{font-size:1.6rem}a{color:#116145}nav{display:flex;gap:1.2rem;flex-wrap:wrap;margin-top:1.5rem}</style></head>
|
||||
<body><main><p>InvesteMoz · 403</p><h1>Criação de oportunidade indisponível</h1><p role="alert">{{ $reason }}</p><p>Nenhum rascunho foi criado. A sessão mantém as permissões já atribuídas.</p><nav aria-label="Próximos passos"><a href="/minhas-oportunidades">Voltar às oportunidades</a><a href="/perfil/promotor">Consultar o perfil de Promotor</a><a href="/apoio">Pedir apoio</a></nav></main></body></html>
|
||||
Reference in New Issue
Block a user