1390 lines
64 KiB
TypeScript
1390 lines
64 KiB
TypeScript
import { Link, router, useForm } from '@inertiajs/react';
|
|
import InvestmentTerritory from '@/components/investment-territory';
|
|
import InvestmentMapPanel from '@/components/investment-map-panel';
|
|
import {
|
|
TerritoryFields,
|
|
type TerritoryOption,
|
|
} from '@/components/investment-territory';
|
|
import { useState } from 'react';
|
|
import { Frame, Field, input, button, card, api } from './shared';
|
|
import PartnershipSourceLinks from '@/components/partnership-source-links';
|
|
import ZoneRelations from './zone-relations';
|
|
import ZoneMap from './zone-map';
|
|
import ZoneAttachments from './zone-attachments';
|
|
import type { ZoneTargets } from './zone-relations';
|
|
|
|
type Zone = {
|
|
id: string;
|
|
version_no: number;
|
|
code: string;
|
|
category: string;
|
|
name: string;
|
|
name_en: string | null;
|
|
description: string | null;
|
|
description_en: string | null;
|
|
province: string | null;
|
|
district: string | null;
|
|
operator_id?: string;
|
|
legal_source_id?: string;
|
|
publication_status?: string;
|
|
validation_status: string;
|
|
physical_category?: string | null;
|
|
legal_regime?: string | null;
|
|
operational_status?: string;
|
|
development_status?: string;
|
|
availability_status?: string;
|
|
area_value?: string | null;
|
|
area_unit?: string | null;
|
|
area_components?: unknown[];
|
|
source_evidence?: {
|
|
title: string;
|
|
url: string;
|
|
source_type: string;
|
|
supports: string;
|
|
source_date?: string | null;
|
|
}[];
|
|
aliases?: string[];
|
|
activities?: {
|
|
name: string;
|
|
status: string;
|
|
source_reference?: string | null;
|
|
}[];
|
|
resources?: {
|
|
name: string;
|
|
status: string;
|
|
source_reference?: string | null;
|
|
}[];
|
|
historical_territory?: {
|
|
name: string;
|
|
district?: string;
|
|
province?: string;
|
|
source_reference?: string;
|
|
} | null;
|
|
};
|
|
type Source = {
|
|
id: string;
|
|
title: string;
|
|
url: string;
|
|
diploma: string;
|
|
article: string;
|
|
competent_entity: string;
|
|
valid_from: string;
|
|
valid_until: string | null;
|
|
version_no: number;
|
|
validation_status: string;
|
|
};
|
|
type ZoneEditorForm = {
|
|
version_no: number;
|
|
code: string;
|
|
category: string;
|
|
physical_category: string;
|
|
legal_regime: string;
|
|
operational_status: string;
|
|
development_status: string;
|
|
availability_status: string;
|
|
area_value: string;
|
|
area_unit: string;
|
|
area_components_json: string;
|
|
source_evidence_json: string;
|
|
activities: {
|
|
name: string;
|
|
status: string;
|
|
source_reference: string | null;
|
|
}[];
|
|
resources: {
|
|
name: string;
|
|
status: string;
|
|
source_reference: string | null;
|
|
}[];
|
|
aliases_text: string;
|
|
historical_name: string;
|
|
historical_district: string;
|
|
historical_province: string;
|
|
historical_source_reference: string;
|
|
name: string;
|
|
name_en: string;
|
|
description: string;
|
|
description_en: string;
|
|
operator_id: string;
|
|
legal_source_id: string;
|
|
};
|
|
type Props = {
|
|
targets: ZoneTargets | null;
|
|
related: { id: string; title: string }[];
|
|
relations: {
|
|
id: string;
|
|
version_no: number;
|
|
association_type: string;
|
|
validation_status: string;
|
|
}[];
|
|
geometries: {
|
|
id: string;
|
|
version_no: number;
|
|
purpose: string;
|
|
validation_status: string;
|
|
}[];
|
|
record: Zone;
|
|
management: boolean;
|
|
zoneExtensionsAvailable?: boolean;
|
|
source: Source | null;
|
|
operator: string | null;
|
|
operators: { id: string; name: string }[];
|
|
legalSources: Source[];
|
|
links: {
|
|
id: string;
|
|
item_id: string;
|
|
association_type: string;
|
|
validation_status: string;
|
|
version_no: number;
|
|
}[];
|
|
revisions: { version_no: number; action: string; created_at: string }[];
|
|
locations: {
|
|
id: string;
|
|
name: string;
|
|
location_type: string;
|
|
scope_type: string;
|
|
source_reference: string;
|
|
validation_status: string;
|
|
}[];
|
|
attachments: {
|
|
id: string;
|
|
kind: string;
|
|
caption: string;
|
|
source_reference: string;
|
|
source_date: string | null;
|
|
rights_status?: string;
|
|
rights_basis?: string | null;
|
|
personal_data_status?: string;
|
|
review_status?: string;
|
|
reviewed_by?: number | null;
|
|
independent_review?: boolean;
|
|
publicly_selected?: boolean;
|
|
uploaded_by?: number;
|
|
version_no?: number;
|
|
file_name?: string;
|
|
media_type: string;
|
|
size_bytes: number | null;
|
|
download_url: string;
|
|
}[];
|
|
opportunities: {
|
|
data: { id: number; title: string; slug: string }[];
|
|
next_page_url: string | null;
|
|
prev_page_url: string | null;
|
|
} | null;
|
|
};
|
|
export default function ZonePage(props: Props) {
|
|
return (
|
|
<Editor
|
|
key={`${props.record.id}:${props.record.version_no}`}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
function Editor({
|
|
targets,
|
|
related,
|
|
relations,
|
|
geometries,
|
|
record: z,
|
|
management,
|
|
zoneExtensionsAvailable = false,
|
|
source,
|
|
operator,
|
|
operators,
|
|
legalSources,
|
|
links,
|
|
revisions,
|
|
locations,
|
|
attachments,
|
|
opportunities,
|
|
}: Props) {
|
|
const [message, setMessage] = useState('');
|
|
const [busy, setBusy] = useState(false);
|
|
const [locationPath, setLocationPath] = useState<TerritoryOption[]>([]);
|
|
const [locationSource, setLocationSource] = useState('');
|
|
const [locationScope, setLocationScope] = useState('administrative');
|
|
const [activityName, setActivityName] = useState('');
|
|
const [activityStatus, setActivityStatus] = useState('potential');
|
|
const [activitySource, setActivitySource] = useState('');
|
|
const [resourceName, setResourceName] = useState('');
|
|
const [resourceStatus, setResourceStatus] = useState('unconfirmed');
|
|
const [resourceSource, setResourceSource] = useState('');
|
|
const [_attachmentFile, _setAttachmentFile] = useState<File | null>(null);
|
|
const [_attachmentKind, _setAttachmentKind] = useState('legal_instrument');
|
|
const [_attachmentCaption, _setAttachmentCaption] = useState('');
|
|
const [_attachmentSource, _setAttachmentSource] = useState('');
|
|
const [_attachmentSourceDate, _setAttachmentSourceDate] = useState('');
|
|
const [_attachmentRightsBasis, _setAttachmentRightsBasis] = useState('');
|
|
const [_attachmentRightsStatus, _setAttachmentRightsStatus] =
|
|
useState('pending');
|
|
const [_reviewChoices, _setReviewChoices] = useState<
|
|
Record<string, { rights: string; personal: string }>
|
|
>({});
|
|
const form = useForm<ZoneEditorForm>({
|
|
version_no: z.version_no,
|
|
code: z.code,
|
|
category: z.category,
|
|
physical_category: z.physical_category ?? 'unknown',
|
|
legal_regime: z.legal_regime ?? 'pending',
|
|
operational_status: z.operational_status ?? 'unknown',
|
|
development_status: z.development_status ?? 'unknown',
|
|
availability_status: z.availability_status ?? 'not_informed',
|
|
area_value: z.area_value ?? '',
|
|
area_unit: z.area_unit ?? '',
|
|
area_components_json: JSON.stringify(z.area_components ?? [], null, 2),
|
|
source_evidence_json: JSON.stringify(z.source_evidence ?? [], null, 2),
|
|
activities: (z.activities ?? []).map((activity) => ({
|
|
...activity,
|
|
source_reference: activity.source_reference ?? null,
|
|
})),
|
|
resources: (z.resources ?? []).map((resource) => ({
|
|
...resource,
|
|
source_reference: resource.source_reference ?? null,
|
|
})),
|
|
aliases_text: (z.aliases ?? []).join('\n'),
|
|
historical_name: z.historical_territory?.name ?? '',
|
|
historical_district: z.historical_territory?.district ?? '',
|
|
historical_province: z.historical_territory?.province ?? '',
|
|
historical_source_reference:
|
|
z.historical_territory?.source_reference ?? '',
|
|
name: z.name,
|
|
name_en: z.name_en ?? '',
|
|
description: z.description ?? '',
|
|
description_en: z.description_en ?? '',
|
|
operator_id: z.operator_id ?? '',
|
|
legal_source_id: z.legal_source_id ?? '',
|
|
});
|
|
async function action(url: string, data: unknown) {
|
|
setBusy(true);
|
|
setMessage('');
|
|
try {
|
|
await api(url, data);
|
|
router.reload();
|
|
} catch (e) {
|
|
setMessage(e instanceof Error ? e.message : 'Falha na operação.');
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
}
|
|
return (
|
|
<Frame title={z.name}>
|
|
{!management && <PartnershipSourceLinks type="zone" id={z.id} />}
|
|
<p>
|
|
{z.code} · {z.category.toUpperCase()} · {z.validation_status} ·{' '}
|
|
{z.province} {z.district}
|
|
</p>
|
|
<p>
|
|
A ficha é informativa. A associação territorial não atribui
|
|
benefícios, licenças ou autorização aduaneira.
|
|
</p>
|
|
{message && (
|
|
<p role="alert" className={card}>
|
|
{message}
|
|
</p>
|
|
)}
|
|
{management ? (
|
|
<>
|
|
<form
|
|
className={card + ' grid gap-4 md:grid-cols-2'}
|
|
onSubmit={async (e) => {
|
|
e.preventDefault();
|
|
setBusy(true);
|
|
setMessage('');
|
|
try {
|
|
const {
|
|
area_components_json,
|
|
source_evidence_json,
|
|
...base
|
|
} = form.data;
|
|
await api(
|
|
`/api/v2/investment/admin/zones/${z.id}`,
|
|
{
|
|
...base,
|
|
area_components:
|
|
JSON.parse(area_components_json),
|
|
source_evidence:
|
|
JSON.parse(source_evidence_json),
|
|
_method: 'PUT',
|
|
},
|
|
);
|
|
router.reload();
|
|
} catch (failure) {
|
|
setMessage(
|
|
failure instanceof Error
|
|
? failure.message
|
|
: 'Falha ao guardar.',
|
|
);
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
}}
|
|
>
|
|
{(
|
|
[
|
|
['code', 'Código'],
|
|
['name', 'Nome PT'],
|
|
['name_en', 'Nome EN'],
|
|
] as const
|
|
).map(([key, label]) => (
|
|
<Field key={key} label={label}>
|
|
<input
|
|
className={input}
|
|
value={form.data[key]}
|
|
onChange={(e) =>
|
|
form.setData(key, e.target.value)
|
|
}
|
|
/>
|
|
</Field>
|
|
))}
|
|
<Field label="Categoria">
|
|
<select
|
|
className={input}
|
|
value={form.data.category}
|
|
onChange={(e) =>
|
|
form.setData('category', e.target.value)
|
|
}
|
|
>
|
|
<option value="pending">Pendente</option>
|
|
<option value="zee">ZEE</option>
|
|
<option value="zfi">ZFI</option>
|
|
<option value="industrial_park">
|
|
Parque industrial
|
|
</option>
|
|
</select>
|
|
</Field>
|
|
<Field label="Categoria física">
|
|
<select
|
|
className={input}
|
|
value={form.data.physical_category}
|
|
onChange={(e) =>
|
|
form.setData(
|
|
'physical_category',
|
|
e.target.value,
|
|
)
|
|
}
|
|
>
|
|
<option value="unknown">Por confirmar</option>
|
|
<option value="economic_zone">
|
|
Zona económica
|
|
</option>
|
|
<option value="industrial_park">
|
|
Parque industrial
|
|
</option>
|
|
{zoneExtensionsAvailable && (
|
|
<>
|
|
<option value="agro_industrial_park">
|
|
Parque agro-industrial
|
|
</option>
|
|
<option value="industrial_logistics_park">
|
|
Parque industrial e logístico
|
|
</option>
|
|
</>
|
|
)}
|
|
<option value="industrial_free_zone">
|
|
Zona franca industrial
|
|
</option>
|
|
<option value="integrated_tourism_area">
|
|
Área de turismo integrado
|
|
</option>
|
|
<option value="other">Outra</option>
|
|
</select>
|
|
</Field>
|
|
<Field label="Regime jurídico">
|
|
<select
|
|
className={input}
|
|
value={form.data.legal_regime}
|
|
onChange={(e) =>
|
|
form.setData('legal_regime', e.target.value)
|
|
}
|
|
>
|
|
<option value="pending">
|
|
Pendente de confirmação
|
|
</option>
|
|
<option value="zee">ZEE</option>
|
|
<option value="zfi">ZFI</option>
|
|
<option value="general">Regime geral</option>
|
|
<option value="not_applicable">
|
|
Não aplicável
|
|
</option>
|
|
</select>
|
|
</Field>
|
|
<Field label="Estado operacional">
|
|
<select
|
|
className={input}
|
|
value={form.data.operational_status}
|
|
onChange={(e) =>
|
|
form.setData(
|
|
'operational_status',
|
|
e.target.value,
|
|
)
|
|
}
|
|
>
|
|
<option value="unknown">Não confirmado</option>
|
|
<option value="operational">Operacional</option>
|
|
<option value="implementation">
|
|
Em implementação
|
|
</option>
|
|
<option value="planned">Planeado</option>
|
|
<option value="suspended">Suspenso</option>
|
|
</select>
|
|
</Field>
|
|
{zoneExtensionsAvailable && (
|
|
<Field label="Estado de desenvolvimento">
|
|
<select
|
|
className={input}
|
|
value={form.data.development_status}
|
|
onChange={(e) =>
|
|
form.setData(
|
|
'development_status',
|
|
e.target.value,
|
|
)
|
|
}
|
|
>
|
|
<option value="unknown">
|
|
Por confirmar
|
|
</option>
|
|
<option value="announced">Anunciado</option>
|
|
<option value="planned">Planeado</option>
|
|
<option value="in_development">
|
|
Em desenvolvimento
|
|
</option>
|
|
<option value="partially_operational">
|
|
Parcialmente operacional
|
|
</option>
|
|
<option value="operational">
|
|
Operacional
|
|
</option>
|
|
<option value="suspended">Suspenso</option>
|
|
</select>
|
|
</Field>
|
|
)}
|
|
{zoneExtensionsAvailable && (
|
|
<Field label="Disponibilidade para instalação">
|
|
<select
|
|
className={input}
|
|
value={form.data.availability_status}
|
|
onChange={(e) =>
|
|
form.setData(
|
|
'availability_status',
|
|
e.target.value,
|
|
)
|
|
}
|
|
>
|
|
<option value="not_informed">
|
|
Não informada
|
|
</option>
|
|
<option value="confirmed">
|
|
Confirmada
|
|
</option>
|
|
<option value="unavailable">
|
|
Indisponível
|
|
</option>
|
|
<option value="reported_unverified">
|
|
Reportada, por verificar
|
|
</option>
|
|
</select>
|
|
</Field>
|
|
)}
|
|
<Field label="Área documentada">
|
|
<input
|
|
className={input}
|
|
type="number"
|
|
min="0"
|
|
step="0.0001"
|
|
value={form.data.area_value}
|
|
onChange={(e) =>
|
|
form.setData('area_value', e.target.value)
|
|
}
|
|
/>
|
|
</Field>
|
|
<Field label="Unidade da área">
|
|
<select
|
|
className={input}
|
|
value={form.data.area_unit}
|
|
onChange={(e) =>
|
|
form.setData('area_unit', e.target.value)
|
|
}
|
|
>
|
|
<option value="">Por confirmar</option>
|
|
<option value="ha">hectares (ha)</option>
|
|
<option value="km2">
|
|
quilómetros quadrados (km²)
|
|
</option>
|
|
</select>
|
|
</Field>
|
|
{zoneExtensionsAvailable && (
|
|
<Field label="Áreas por âmbito (JSON; valor, unidade, fonte, data, estado)">
|
|
<textarea
|
|
className={input}
|
|
rows={6}
|
|
value={form.data.area_components_json}
|
|
onChange={(e) =>
|
|
form.setData(
|
|
'area_components_json',
|
|
e.target.value,
|
|
)
|
|
}
|
|
/>
|
|
</Field>
|
|
)}
|
|
{zoneExtensionsAvailable && (
|
|
<Field label="Evidência e fontes (JSON; tipo e o que comprova)">
|
|
<textarea
|
|
className={input}
|
|
rows={6}
|
|
value={form.data.source_evidence_json}
|
|
onChange={(e) =>
|
|
form.setData(
|
|
'source_evidence_json',
|
|
e.target.value,
|
|
)
|
|
}
|
|
/>
|
|
</Field>
|
|
)}
|
|
<Field label="Designações alternativas (uma por linha)">
|
|
<textarea
|
|
className={input}
|
|
rows={2}
|
|
value={form.data.aliases_text}
|
|
onChange={(e) =>
|
|
form.setData('aliases_text', e.target.value)
|
|
}
|
|
/>
|
|
</Field>
|
|
<Field label="Localização histórica">
|
|
<input
|
|
className={input}
|
|
value={form.data.historical_name}
|
|
onChange={(e) =>
|
|
form.setData(
|
|
'historical_name',
|
|
e.target.value,
|
|
)
|
|
}
|
|
/>
|
|
</Field>
|
|
<Field label="Distrito histórico">
|
|
<input
|
|
className={input}
|
|
value={form.data.historical_district}
|
|
onChange={(e) =>
|
|
form.setData(
|
|
'historical_district',
|
|
e.target.value,
|
|
)
|
|
}
|
|
/>
|
|
</Field>
|
|
<Field label="Província histórica">
|
|
<input
|
|
className={input}
|
|
value={form.data.historical_province}
|
|
onChange={(e) =>
|
|
form.setData(
|
|
'historical_province',
|
|
e.target.value,
|
|
)
|
|
}
|
|
/>
|
|
</Field>
|
|
<Field label="Fonte da localização histórica">
|
|
<input
|
|
className={input}
|
|
value={form.data.historical_source_reference}
|
|
onChange={(e) =>
|
|
form.setData(
|
|
'historical_source_reference',
|
|
e.target.value,
|
|
)
|
|
}
|
|
/>
|
|
</Field>
|
|
<section
|
|
className="space-y-3 md:col-span-2"
|
|
aria-label="Actividades documentadas"
|
|
>
|
|
<h2 className="font-semibold">
|
|
Actividades e sectores
|
|
</h2>
|
|
{form.data.activities.map((activity, index) => (
|
|
<p key={`${activity.name}-${index}`}>
|
|
{activity.name} · {activity.status} ·{' '}
|
|
{activity.source_reference ??
|
|
'fonte por registar'}
|
|
</p>
|
|
))}
|
|
<div className="grid gap-2 md:grid-cols-3">
|
|
<input
|
|
className={input}
|
|
aria-label="Actividade"
|
|
placeholder="Actividade"
|
|
value={activityName}
|
|
onChange={(e) =>
|
|
setActivityName(e.target.value)
|
|
}
|
|
/>
|
|
<select
|
|
className={input}
|
|
aria-label="Estado da actividade"
|
|
value={activityStatus}
|
|
onChange={(e) =>
|
|
setActivityStatus(e.target.value)
|
|
}
|
|
>
|
|
<option value="potential">
|
|
Potencial referido pela fonte
|
|
</option>
|
|
<option value="proposed">Proposta</option>
|
|
<option value="authorized">
|
|
Autorizada
|
|
</option>
|
|
<option value="conditional">
|
|
Condicionada
|
|
</option>
|
|
<option value="excluded">Excluída</option>
|
|
</select>
|
|
<input
|
|
className={input}
|
|
aria-label="Fonte da actividade"
|
|
placeholder="URL ou referência"
|
|
value={activitySource}
|
|
onChange={(e) =>
|
|
setActivitySource(e.target.value)
|
|
}
|
|
/>
|
|
</div>
|
|
<button
|
|
type="button"
|
|
className={button}
|
|
disabled={!activityName.trim()}
|
|
onClick={() => {
|
|
form.setData('activities', [
|
|
...form.data.activities,
|
|
{
|
|
name: activityName.trim(),
|
|
status: activityStatus,
|
|
source_reference:
|
|
activitySource.trim() || null,
|
|
},
|
|
]);
|
|
setActivityName('');
|
|
setActivitySource('');
|
|
}}
|
|
>
|
|
Adicionar actividade
|
|
</button>
|
|
</section>
|
|
<section
|
|
className="space-y-3 md:col-span-2"
|
|
aria-label="Infra-estruturas e recursos"
|
|
>
|
|
<h2 className="font-semibold">
|
|
Infra-estruturas e recursos
|
|
</h2>
|
|
{form.data.resources.map((resource, index) => (
|
|
<p key={`${resource.name}-${index}`}>
|
|
{resource.name} · {resource.status} ·{' '}
|
|
{resource.source_reference ??
|
|
'fonte por registar'}
|
|
</p>
|
|
))}
|
|
<div className="grid gap-2 md:grid-cols-3">
|
|
<input
|
|
className={input}
|
|
aria-label="Recurso"
|
|
placeholder="Estrada, energia, água…"
|
|
value={resourceName}
|
|
onChange={(e) =>
|
|
setResourceName(e.target.value)
|
|
}
|
|
/>
|
|
<select
|
|
className={input}
|
|
aria-label="Estado do recurso"
|
|
value={resourceStatus}
|
|
onChange={(e) =>
|
|
setResourceStatus(e.target.value)
|
|
}
|
|
>
|
|
<option value="existing">
|
|
Existente, fonte confirmada
|
|
</option>
|
|
<option value="planned">Planeado</option>
|
|
<option value="unconfirmed">
|
|
Não confirmado
|
|
</option>
|
|
</select>
|
|
<input
|
|
className={input}
|
|
aria-label="Fonte do recurso"
|
|
placeholder="URL ou referência"
|
|
value={resourceSource}
|
|
onChange={(e) =>
|
|
setResourceSource(e.target.value)
|
|
}
|
|
/>
|
|
</div>
|
|
<button
|
|
type="button"
|
|
className={button}
|
|
disabled={!resourceName.trim()}
|
|
onClick={() => {
|
|
form.setData('resources', [
|
|
...form.data.resources,
|
|
{
|
|
name: resourceName.trim(),
|
|
status: resourceStatus,
|
|
source_reference:
|
|
resourceSource.trim() || null,
|
|
},
|
|
]);
|
|
setResourceName('');
|
|
setResourceSource('');
|
|
}}
|
|
>
|
|
Adicionar recurso
|
|
</button>
|
|
</section>
|
|
{(
|
|
[
|
|
['description', 'Descrição PT'],
|
|
['description_en', 'Descrição EN'],
|
|
] as const
|
|
).map(([key, label]) => (
|
|
<Field key={key} label={label}>
|
|
<textarea
|
|
className={input}
|
|
value={form.data[key]}
|
|
onChange={(e) =>
|
|
form.setData(key, e.target.value)
|
|
}
|
|
/>
|
|
</Field>
|
|
))}
|
|
<Field label="Operador cadastrado">
|
|
<select
|
|
className={input}
|
|
value={form.data.operator_id}
|
|
onChange={(e) =>
|
|
form.setData('operator_id', e.target.value)
|
|
}
|
|
>
|
|
<option value="">Por confirmar</option>
|
|
{operators.map((o) => (
|
|
<option key={o.id} value={o.id}>
|
|
{o.name}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</Field>
|
|
<Field label="Fonte jurídica">
|
|
<select
|
|
className={input}
|
|
value={form.data.legal_source_id}
|
|
onChange={(e) =>
|
|
form.setData(
|
|
'legal_source_id',
|
|
e.target.value,
|
|
)
|
|
}
|
|
>
|
|
<option value="">Por confirmar</option>
|
|
{legalSources.map((s) => (
|
|
<option key={s.id} value={s.id}>
|
|
{s.title} · {s.validation_status}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</Field>
|
|
<button disabled={busy} className={button}>
|
|
Guardar rascunho
|
|
</button>
|
|
</form>
|
|
<ZoneAttachments
|
|
zoneId={z.id}
|
|
attachments={attachments}
|
|
management={true}
|
|
zonePublished={z.publication_status === 'published'}
|
|
/>
|
|
<section
|
|
className={card + ' space-y-4'}
|
|
aria-label="Localizações documentadas"
|
|
>
|
|
<h2 className="text-xl font-bold">
|
|
Localizações documentadas
|
|
</h2>
|
|
<p>
|
|
As localizações acrescentadas ficam pendentes até
|
|
revisão independente. Não são inferidas pelo nome.
|
|
</p>
|
|
{locations.map((location) => (
|
|
<div
|
|
key={location.id}
|
|
className="rounded border p-3"
|
|
>
|
|
<p>
|
|
{location.name} · {location.scope_type} ·{' '}
|
|
{location.validation_status}
|
|
</p>
|
|
<p className="text-sm">
|
|
{location.source_reference}
|
|
</p>
|
|
{location.validation_status === 'pending' && (
|
|
<button
|
|
type="button"
|
|
className={button}
|
|
disabled={busy}
|
|
onClick={() =>
|
|
action(
|
|
`/api/v2/investment/admin/zone-locations/${location.id}/validate`,
|
|
{ version_no: 1 },
|
|
)
|
|
}
|
|
>
|
|
Rever localização
|
|
</button>
|
|
)}
|
|
</div>
|
|
))}
|
|
<TerritoryFields
|
|
endpoint="/management/territory-options"
|
|
onChange={setLocationPath}
|
|
/>
|
|
<Field label="Tipo de abrangência">
|
|
<select
|
|
className={input}
|
|
value={locationScope}
|
|
onChange={(event) =>
|
|
setLocationScope(event.target.value)
|
|
}
|
|
>
|
|
<option value="legal_scope">
|
|
Perímetro legal
|
|
</option>
|
|
<option value="administrative">
|
|
Unidade administrativa
|
|
</option>
|
|
<option value="site">Instalação/local</option>
|
|
<option value="influence">
|
|
Área de influência
|
|
</option>
|
|
</select>
|
|
</Field>
|
|
<Field label="Fonte e fundamento da associação">
|
|
<input
|
|
className={input}
|
|
minLength={10}
|
|
maxLength={2000}
|
|
value={locationSource}
|
|
onChange={(event) =>
|
|
setLocationSource(event.target.value)
|
|
}
|
|
/>
|
|
</Field>
|
|
<button
|
|
type="button"
|
|
className={button}
|
|
disabled={
|
|
busy ||
|
|
!locationPath.length ||
|
|
locationSource.length < 10
|
|
}
|
|
onClick={() => {
|
|
const selected =
|
|
locationPath[locationPath.length - 1];
|
|
void action(
|
|
`/api/v2/investment/admin/zones/${z.id}`,
|
|
{
|
|
...form.data,
|
|
locations: [
|
|
{
|
|
geo_location_id: selected.id,
|
|
scope_type: locationScope,
|
|
source_reference:
|
|
locationSource,
|
|
},
|
|
],
|
|
_method: 'PUT',
|
|
},
|
|
);
|
|
}}
|
|
>
|
|
Guardar outra localização
|
|
</button>
|
|
</section>
|
|
<section className={card}>
|
|
<h2 className="text-xl font-bold">
|
|
Publicação informativa
|
|
</h2>
|
|
<p>
|
|
Versão {z.version_no}. Confirme os dados, a fonte e
|
|
a localização antes de publicar. A publicação não
|
|
confirma estado operacional, disponibilidade para
|
|
investimento ou benefícios fiscais. Guarde primeiro
|
|
as alterações.
|
|
</p>
|
|
<div className="flex gap-4">
|
|
<button
|
|
className={button}
|
|
disabled={busy || form.isDirty}
|
|
onClick={() =>
|
|
action(
|
|
`/api/v2/investment/admin/zones/${z.id}/publish`,
|
|
{
|
|
version_no: z.version_no,
|
|
},
|
|
)
|
|
}
|
|
>
|
|
Publicar zona
|
|
</button>
|
|
<button
|
|
className={button}
|
|
disabled={busy}
|
|
onClick={() =>
|
|
action(
|
|
`/api/v2/investment/admin/zones/${z.id}/suspend`,
|
|
{
|
|
version_no: z.version_no,
|
|
},
|
|
)
|
|
}
|
|
>
|
|
Suspender publicação
|
|
</button>
|
|
</div>
|
|
</section>
|
|
<section className={card}>
|
|
<h2 className="text-xl font-bold">Fontes por rever</h2>
|
|
{legalSources.map((s) => (
|
|
<article key={s.id} className="my-4">
|
|
<p>
|
|
{s.title} · {s.diploma} · {s.article} ·{' '}
|
|
{s.validation_status}
|
|
</p>
|
|
<a
|
|
className="underline"
|
|
href={s.url}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
>
|
|
Consultar documento
|
|
</a>
|
|
<div className="flex gap-4">
|
|
{s.validation_status === 'pending' && (
|
|
<button
|
|
className={button}
|
|
disabled={busy}
|
|
onClick={() =>
|
|
action(
|
|
`/api/v2/investment/admin/legal-sources/${s.id}/validate`,
|
|
{
|
|
version_no:
|
|
s.version_no,
|
|
},
|
|
)
|
|
}
|
|
>
|
|
Validar fonte
|
|
</button>
|
|
)}
|
|
{s.validation_status !== 'revoked' && (
|
|
<button
|
|
className={button}
|
|
disabled={busy}
|
|
onClick={() =>
|
|
action(
|
|
`/api/v2/investment/admin/legal-sources/${s.id}/revoke`,
|
|
{
|
|
version_no:
|
|
s.version_no,
|
|
},
|
|
)
|
|
}
|
|
>
|
|
Revogar referência
|
|
</button>
|
|
)}
|
|
</div>
|
|
</article>
|
|
))}
|
|
</section>
|
|
<form
|
|
className={card + ' grid gap-4 md:grid-cols-2'}
|
|
onSubmit={(e) => {
|
|
e.preventDefault();
|
|
void action(
|
|
'/api/v2/investment/admin/legal-sources',
|
|
Object.fromEntries(
|
|
new FormData(e.currentTarget),
|
|
),
|
|
);
|
|
}}
|
|
>
|
|
<h2 className="text-xl font-bold md:col-span-2">
|
|
Registar fonte jurídica
|
|
</h2>
|
|
{(
|
|
[
|
|
['title', 'Título', 'text'],
|
|
['url', 'URL HTTPS', 'url'],
|
|
['diploma', 'Diploma', 'text'],
|
|
['article', 'Artigo', 'text'],
|
|
[
|
|
'competent_entity',
|
|
'Entidade competente indicada no diploma',
|
|
'text',
|
|
],
|
|
['valid_from', 'Início de vigência', 'date'],
|
|
[
|
|
'valid_until',
|
|
'Fim de vigência, se aplicável',
|
|
'date',
|
|
],
|
|
] as const
|
|
).map(([name, label, type]) => (
|
|
<Field key={name} label={label}>
|
|
<input
|
|
className={input}
|
|
name={name}
|
|
type={type}
|
|
required={name !== 'valid_until'}
|
|
/>
|
|
</Field>
|
|
))}
|
|
<button className={button} disabled={busy}>
|
|
Registar para revisão
|
|
</button>
|
|
</form>
|
|
<section className={card}>
|
|
<h2 className="text-xl font-bold">
|
|
Associações para revisão
|
|
</h2>
|
|
{links.map((l) => (
|
|
<div key={l.id}>
|
|
<p>
|
|
{l.item_id} · {l.association_type} ·{' '}
|
|
{l.validation_status}
|
|
</p>
|
|
<button
|
|
className={button}
|
|
disabled={busy}
|
|
onClick={() =>
|
|
action(
|
|
`/api/v2/investment/admin/zone-links/${l.id}/${l.validation_status === 'pending' ? 'validate' : 'revoke'}`,
|
|
{ version_no: l.version_no },
|
|
)
|
|
}
|
|
>
|
|
{l.validation_status === 'pending'
|
|
? 'Validar associação'
|
|
: 'Revogar associação'}
|
|
</button>
|
|
</div>
|
|
))}
|
|
</section>
|
|
<section className={card}>
|
|
<h2 className="text-xl font-bold">
|
|
Histórico editorial
|
|
</h2>
|
|
{revisions.map((r) => (
|
|
<p key={r.version_no}>
|
|
Versão {r.version_no} · {r.action} ·{' '}
|
|
{r.created_at}
|
|
</p>
|
|
))}
|
|
</section>
|
|
{targets && (
|
|
<ZoneRelations
|
|
id={z.id}
|
|
targets={targets}
|
|
sources={legalSources}
|
|
relations={relations}
|
|
geometries={geometries}
|
|
busy={busy}
|
|
action={action}
|
|
/>
|
|
)}
|
|
</>
|
|
) : (
|
|
<>
|
|
<p className="whitespace-pre-line">{z.description}</p>
|
|
<p>
|
|
Categoria física:{' '}
|
|
{z.physical_category ?? 'Por confirmar'} · Regime
|
|
jurídico: {z.legal_regime ?? 'Por confirmar'}
|
|
{zoneExtensionsAvailable
|
|
? ` · Desenvolvimento: ${z.development_status ?? 'Por confirmar'} · Disponibilidade: ${z.availability_status ?? 'Não informada'}`
|
|
: ''}
|
|
</p>
|
|
{z.area_value && (
|
|
<p>
|
|
Área documentada: {z.area_value} {z.area_unit}
|
|
</p>
|
|
)}
|
|
{zoneExtensionsAvailable && !!z.area_components?.length && (
|
|
<section className={card}>
|
|
<h2 className="font-bold">Áreas por âmbito</h2>
|
|
<ul>
|
|
{z.area_components.map((area, index) => (
|
|
<li key={index}>{JSON.stringify(area)}</li>
|
|
))}
|
|
</ul>
|
|
</section>
|
|
)}
|
|
{zoneExtensionsAvailable && !!z.source_evidence?.length && (
|
|
<section className={card}>
|
|
<h2 className="font-bold">
|
|
Fontes e o que comprovam
|
|
</h2>
|
|
<ul>
|
|
{z.source_evidence.map((evidence) => (
|
|
<li key={evidence.url}>
|
|
<a
|
|
className="underline"
|
|
href={evidence.url}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
>
|
|
{evidence.title}
|
|
</a>
|
|
{evidence.source_date
|
|
? ` · ${evidence.source_date}`
|
|
: ' · data não indicada'}{' '}
|
|
· {evidence.source_type} ·{' '}
|
|
{evidence.supports}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
<p>
|
|
Esta informação descreve o que a fonte declara;
|
|
não confirma vigência legal, benefícios, estado
|
|
operacional ou disponibilidade para
|
|
investimento.
|
|
</p>
|
|
</section>
|
|
)}
|
|
{z.historical_territory?.name && (
|
|
<p>
|
|
Localização histórica: {z.historical_territory.name}
|
|
{z.historical_territory.district
|
|
? ` · ${z.historical_territory.district}`
|
|
: ''}
|
|
{z.historical_territory.province
|
|
? ` · ${z.historical_territory.province}`
|
|
: ''}
|
|
</p>
|
|
)}
|
|
{z.activities?.length ? (
|
|
<section className={card}>
|
|
<h2 className="text-xl font-bold">
|
|
Actividades e sectores referidos
|
|
</h2>
|
|
<ul>
|
|
{z.activities.map((activity, index) => (
|
|
<li key={`${activity.name}-${index}`}>
|
|
{activity.name} ·{' '}
|
|
{activity.status === 'potential'
|
|
? 'potencial referido; não confirmado como autorizado'
|
|
: activity.status === 'proposed'
|
|
? 'proposto; não confirmado como autorizado'
|
|
: activity.status === 'authorized'
|
|
? 'autorizado segundo a fonte indicada'
|
|
: activity.status ===
|
|
'conditional'
|
|
? 'condicionado segundo a fonte indicada'
|
|
: 'excluído segundo a fonte indicada'}
|
|
{activity.source_reference
|
|
? ` · ${activity.source_reference}`
|
|
: ''}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</section>
|
|
) : null}
|
|
{z.resources?.length ? (
|
|
<section className={card}>
|
|
<h2 className="text-xl font-bold">
|
|
Infra-estruturas e recursos
|
|
</h2>
|
|
{z.resources.map((resource, index) => (
|
|
<p key={`${resource.name}-${index}`}>
|
|
{resource.name} · {resource.status}
|
|
{resource.source_reference
|
|
? ` · ${resource.source_reference}`
|
|
: ''}
|
|
</p>
|
|
))}
|
|
</section>
|
|
) : null}
|
|
{locations.length > 0 && (
|
|
<section className={card}>
|
|
<h2 className="text-xl font-bold">
|
|
Abrangência territorial
|
|
</h2>
|
|
<ul>
|
|
{locations.map((location) => (
|
|
<li key={location.id}>
|
|
{location.name} (
|
|
{location.location_type}) ·{' '}
|
|
{location.scope_type}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</section>
|
|
)}
|
|
<ZoneMap id={z.id} />
|
|
{z.description_en && (
|
|
<details>
|
|
<summary>English description</summary>
|
|
<p lang="en" className="whitespace-pre-line">
|
|
{z.description_en}
|
|
</p>
|
|
</details>
|
|
)}
|
|
<p>
|
|
Operador:{' '}
|
|
{operator ?? 'Informação pública por disponibilizar'}
|
|
</p>
|
|
<ZoneAttachments
|
|
zoneId={z.id}
|
|
attachments={attachments}
|
|
management={false}
|
|
zonePublished={z.publication_status === 'published'}
|
|
/>
|
|
{source && (
|
|
<section className={card}>
|
|
<h2 className="text-xl font-bold">
|
|
Fonte e vigência
|
|
</h2>
|
|
{source.validation_status !== 'validated' && (
|
|
<p role="status">
|
|
Referência documental registada; validação
|
|
jurídica da fonte pendente. A ficha não
|
|
confirma vigência, benefício,
|
|
operacionalidade ou disponibilidade.
|
|
</p>
|
|
)}
|
|
{source.validation_status !== 'validated' && (
|
|
<p role="status">
|
|
Referência documental registada; validação
|
|
jurídica da fonte pendente. A ficha não
|
|
confirma vigência, benefício fiscal,
|
|
operacionalidade ou disponibilidade.
|
|
</p>
|
|
)}
|
|
<a
|
|
className="underline"
|
|
href={source.url}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
>
|
|
{source.title}
|
|
</a>
|
|
<p>
|
|
{source.diploma} · {source.article} ·{' '}
|
|
{source.competent_entity}
|
|
</p>
|
|
<p>
|
|
{source.valid_from} —{' '}
|
|
{source.valid_until ??
|
|
'Sem fim indicado na referência'}{' '}
|
|
· Versão {source.version_no}
|
|
</p>
|
|
</section>
|
|
)}
|
|
<section className={card}>
|
|
<h2 className="text-xl font-bold">
|
|
Investimentos relacionados
|
|
</h2>
|
|
{opportunities?.data.map((o) => (
|
|
<p key={o.id}>
|
|
<Link
|
|
className="underline"
|
|
href={`/oportunidades/${o.slug}?zone_id=${z.id}`}
|
|
>
|
|
{o.title}
|
|
</Link>
|
|
</p>
|
|
))}
|
|
{!opportunities?.data.length && (
|
|
<p>Sem investimentos publicados associados.</p>
|
|
)}
|
|
<nav aria-label="Paginação">
|
|
{opportunities?.prev_page_url && (
|
|
<Link href={opportunities.prev_page_url}>
|
|
Anterior
|
|
</Link>
|
|
)}{' '}
|
|
{opportunities?.next_page_url && (
|
|
<Link href={opportunities.next_page_url}>
|
|
Seguinte
|
|
</Link>
|
|
)}
|
|
</nav>
|
|
</section>
|
|
<div className="flex flex-wrap gap-3">
|
|
{(
|
|
[
|
|
['interest', 'Manifestar interesse'],
|
|
['dossier', 'Solicitar dossier'],
|
|
['meeting', 'Pedir reunião'],
|
|
] as const
|
|
).map(([intent, label]) => (
|
|
<button
|
|
key={intent}
|
|
className={button}
|
|
onClick={() =>
|
|
router.post('/investidor/manifestacoes', {
|
|
zone_id: z.id,
|
|
intent,
|
|
})
|
|
}
|
|
>
|
|
{label}
|
|
</button>
|
|
))}
|
|
</div>
|
|
<p>
|
|
Pedido assistido com conta e consentimento. Não inicia
|
|
prazo de decisão administrativa nem confirma uma
|
|
reunião.
|
|
</p>
|
|
<section className={card}>
|
|
<h2 className="text-xl font-bold">
|
|
Clusters, corredores e projectos relacionados
|
|
</h2>
|
|
{related.map((r) => (
|
|
<p key={r.id}>
|
|
<Link
|
|
className="underline"
|
|
href={`/carteira/${r.id}`}
|
|
>
|
|
{r.title}
|
|
</Link>
|
|
</p>
|
|
))}
|
|
{!related.length && (
|
|
<p>Sem relações territoriais publicadas.</p>
|
|
)}
|
|
</section>
|
|
</>
|
|
)}
|
|
{management && <InvestmentTerritory kind="zones" id={z.id} />}
|
|
{!management &&
|
|
['zee', 'zfi', 'industrial_park'].includes(z.category) && (
|
|
<InvestmentMapPanel
|
|
filters={{
|
|
[z.category === 'zee'
|
|
? 'zee_id'
|
|
: z.category === 'zfi'
|
|
? 'zfi_id'
|
|
: 'park_id']: z.id,
|
|
}}
|
|
/>
|
|
)}
|
|
</Frame>
|
|
);
|
|
}
|