@@ -1,16 +1,17 @@
|
||||
import { useRef, useState } from "react";
|
||||
import { Link } from "@inertiajs/react";
|
||||
import type { FormEvent } from "react";
|
||||
import { newSubmissionKey } from "@/lib/portal-api";
|
||||
import { Frame, Field, button, card, input } from "./shared";
|
||||
|
||||
type Opportunity = { id: string; slug: string; title: string; sector?: { name: string } | null };
|
||||
type Props = { record: Opportunity; modalities: string[] };
|
||||
type Props = { record: Opportunity; modalities: string[]; returnUrl?: string };
|
||||
type Form = {
|
||||
fullName: string; email: string; phone: string; investorType: string; country: string;
|
||||
sectorInterest: string; modality: string; investmentRange: string; message: string; privacyConsent: boolean; shareWithProponent: boolean;
|
||||
};
|
||||
|
||||
export default function BusinessInterest({ record, modalities }: Props) {
|
||||
export default function BusinessInterest({ record, modalities, returnUrl = "/negocios" }: Props) {
|
||||
const [form, setForm] = useState<Form>({ fullName: "", email: "", phone: "", investorType: "empresa", country: "MZ", sectorInterest: record.sector?.name ?? "", modality: modalities[0] ?? "", investmentRange: "", message: "", privacyConsent: false, shareWithProponent: false });
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
@@ -38,6 +39,7 @@ export default function BusinessInterest({ record, modalities }: Props) {
|
||||
};
|
||||
return (
|
||||
<Frame title="Manifestar interesse">
|
||||
<Link href={returnUrl} className="underline">Voltar à oportunidade</Link>
|
||||
<p>Oportunidade: <strong>{record.title}</strong></p>
|
||||
{receipt ? <section className={card} role="status"><h2 className="text-xl font-bold">Pedido recebido</h2><p>Referência: {receipt}</p><p>A equipa fará a triagem antes de qualquer partilha com o proponente.</p></section> : (
|
||||
<form className={`${card} space-y-4`} onSubmit={submit}>
|
||||
|
||||
@@ -1,32 +1,39 @@
|
||||
import { Link, router } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import { Frame, button, card, input } from "./shared";
|
||||
import { TerritoryFields, type TerritoryOption } from "@/components/investment-territory";
|
||||
|
||||
type PublicBusiness = {
|
||||
id: string; slug: string; title: string; objective?: string | null; stage?: string | null;
|
||||
amount_min?: string | null; amount_max?: string | null; currency?: string | null;
|
||||
sector?: { name: string; slug: string } | null; province?: string | null;
|
||||
};
|
||||
type Props = { results: { data: PublicBusiness[]; links: { url: string | null; label: string; active: boolean }[] }; filters: { q?: string } };
|
||||
type PaginationLink = { url: string | null; label: string; active: boolean };
|
||||
type Props = { results: { data: PublicBusiness[]; links?: PaginationLink[] | { first: string | null; last: string | null; prev: string | null; next: string | null }; meta?: { links?: PaginationLink[]; total?: number } }; filters: { q?: string; province_id?: string; district_id?: string; admin_post_id?: string; locality_id?: string }; territorySelection?: TerritoryOption[] };
|
||||
|
||||
export default function BusinessMarketplace({ results, filters }: Props) {
|
||||
export default function BusinessMarketplace({ results, filters, territorySelection = [] }: Props) {
|
||||
const [query, setQuery] = useState(filters.q ?? "");
|
||||
const [territory, setTerritory] = useState<Record<string, string>>({ province_id: filters.province_id ?? "", district_id: filters.district_id ?? "", admin_post_id: filters.admin_post_id ?? "", locality_id: filters.locality_id ?? "" });
|
||||
const returnQuery = new URLSearchParams({ ...(query ? { q: query } : {}), ...territory }).toString();
|
||||
const paginationLinks = results.meta?.links ?? (Array.isArray(results.links) ? results.links : []);
|
||||
return (
|
||||
<Frame title="Oportunidades de negócio">
|
||||
<p>Explore oportunidades aprovadas para publicação. A informação está sujeita a diligência independente.</p>
|
||||
<form className="flex flex-wrap gap-3" onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
router.get("/negocios", { q: query || undefined }, { preserveState: true, preserveScroll: true });
|
||||
router.get("/negocios", { q: query || undefined, ...territory }, { preserveState: true, preserveScroll: true });
|
||||
}}>
|
||||
<label className="sr-only" htmlFor="business-search">Pesquisar negócios</label>
|
||||
<input id="business-search" className={input} value={query} maxLength={120} onChange={(event) => setQuery(event.target.value)} />
|
||||
<TerritoryFields initial={territorySelection} onChange={(path) => setTerritory({ province_id: path[0]?.id ?? "", district_id: path[1]?.id ?? "", admin_post_id: path[2]?.id ?? "", locality_id: path[3]?.id ?? "" })} />
|
||||
<button className={button}>Pesquisar</button>
|
||||
</form>
|
||||
<p role="status">{results.meta?.total ?? results.data.length} anúncios de negócios publicados</p>
|
||||
{!results.data.length && <p role="status">Não existem oportunidades publicadas com estes critérios.</p>}
|
||||
<ul className="grid gap-4 md:grid-cols-2">
|
||||
{results.data.map((record) => (
|
||||
<li className={card} key={record.id}>
|
||||
<h2 className="text-xl font-bold"><Link className="underline" href={`/negocios/${record.slug}`}>{record.title}</Link></h2>
|
||||
<h2 className="text-xl font-bold"><Link className="underline" href={`/negocios/${record.slug}${returnQuery ? `?${returnQuery}` : ""}`}>{record.title}</Link></h2>
|
||||
<p>{[record.sector?.name, record.province, record.stage].filter(Boolean).join(" · ")}</p>
|
||||
{(record.amount_min || record.amount_max) && <p>{record.amount_min ?? "—"} – {record.amount_max ?? "—"} {record.currency}</p>}
|
||||
{record.objective && <p className="mt-3 line-clamp-3">{record.objective}</p>}
|
||||
@@ -34,7 +41,7 @@ export default function BusinessMarketplace({ results, filters }: Props) {
|
||||
))}
|
||||
</ul>
|
||||
<nav aria-label="Paginação das oportunidades" className="flex flex-wrap gap-3">
|
||||
{results.links.map((link) => link.url ? <Link key={link.label} href={link.url} className={link.active ? "font-bold underline" : "underline"} dangerouslySetInnerHTML={{ __html: link.label }} /> : null)}
|
||||
{paginationLinks.map((link) => link.url ? <Link key={link.label} href={link.url} className={link.active ? "font-bold underline" : "underline"} dangerouslySetInnerHTML={{ __html: link.label }} /> : null)}
|
||||
</nav>
|
||||
</Frame>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { router } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import { Field, input, button, card, api } from "./shared";
|
||||
import { router } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import { Field, input, button, card, api } from './shared';
|
||||
|
||||
export type BusinessObject = {
|
||||
id: string;
|
||||
@@ -9,42 +9,44 @@ export type BusinessObject = {
|
||||
payload: Record<string, string>;
|
||||
};
|
||||
const kinds: Record<string, string> = {
|
||||
company: "Empresa",
|
||||
participation: "Participação",
|
||||
asset: "Activo físico",
|
||||
property: "Imóvel/propriedade",
|
||||
unit: "Unidade imobiliária",
|
||||
improvement: "Benfeitoria",
|
||||
agricultural_investment: "Investimento agrícola",
|
||||
land_right: "Direito fundiário",
|
||||
contract: "Contrato",
|
||||
license: "Licença",
|
||||
authorization: "Autorização",
|
||||
encumbrance: "Ónus ou encargo",
|
||||
valuation: "Avaliação declarada",
|
||||
capital_request: "Pedido de capital",
|
||||
company: 'Empresa',
|
||||
participation: 'Participação',
|
||||
asset: 'Activo físico',
|
||||
property: 'Imóvel/propriedade',
|
||||
unit: 'Unidade imobiliária',
|
||||
improvement: 'Benfeitoria',
|
||||
agricultural_investment: 'Investimento agrícola',
|
||||
land_right: 'Direito fundiário',
|
||||
contract: 'Contrato',
|
||||
license: 'Licença',
|
||||
authorization: 'Autorização',
|
||||
encumbrance: 'Ónus ou encargo',
|
||||
valuation: 'Avaliação declarada',
|
||||
capital_request: 'Pedido de capital',
|
||||
};
|
||||
const fields: Record<string, string> = {
|
||||
label: "Designação reservada",
|
||||
declared_holder: "Titular declarado",
|
||||
document_reference: "Referência documental",
|
||||
source_reference: "Fonte da informação",
|
||||
competent_entity: "Entidade emissora/competente declarada",
|
||||
purpose: "Finalidade autorizada declarada",
|
||||
location_description: "Localização reservada",
|
||||
boundaries_description: "Limites declarados",
|
||||
occupancy: "Ocupação/utilização",
|
||||
condition: "Conservação/operação",
|
||||
encumbrances: "Ónus, garantias ou litígios declarados",
|
||||
restrictions: "Restrições declaradas",
|
||||
required_authorizations: "Autorizações necessárias declaradas",
|
||||
transfer_condition: "Condição de cessão/transmissão declarada",
|
||||
valid_from: "Início de validade",
|
||||
valid_until: "Fim de validade",
|
||||
area: "Área (decimal com ponto)",
|
||||
participation_percent: "Participação (%)",
|
||||
amount: "Valor (decimal com ponto)",
|
||||
currency: "Moeda (código de três letras)",
|
||||
label: 'Designação reservada',
|
||||
declared_holder: 'Titular declarado',
|
||||
document_reference: 'Referência documental',
|
||||
source_reference: 'Fonte da informação',
|
||||
source_date: 'Data da fonte',
|
||||
resource_status: 'Situação do recurso',
|
||||
competent_entity: 'Entidade emissora/competente declarada',
|
||||
purpose: 'Finalidade autorizada declarada',
|
||||
location_description: 'Localização reservada',
|
||||
boundaries_description: 'Limites declarados',
|
||||
occupancy: 'Ocupação/utilização',
|
||||
condition: 'Conservação/operação',
|
||||
encumbrances: 'Ónus, garantias ou litígios declarados',
|
||||
restrictions: 'Restrições declaradas',
|
||||
required_authorizations: 'Autorizações necessárias declaradas',
|
||||
transfer_condition: 'Condição de cessão/transmissão declarada',
|
||||
valid_from: 'Início de validade',
|
||||
valid_until: 'Fim de validade',
|
||||
area: 'Área (decimal com ponto)',
|
||||
participation_percent: 'Participação (%)',
|
||||
amount: 'Valor (decimal com ponto)',
|
||||
currency: 'Moeda (código de três letras)',
|
||||
};
|
||||
export default function BusinessObjects({
|
||||
businessId,
|
||||
@@ -62,16 +64,19 @@ export default function BusinessObjects({
|
||||
const [kind, setKind] = useState(objectKinds[0]);
|
||||
const [objectId, setObjectId] = useState<string | null>(null);
|
||||
const [payload, setPayload] = useState<Record<string, string>>({});
|
||||
const [reason, setReason] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
const [reason, setReason] = useState('');
|
||||
const [error, setError] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
return (
|
||||
<section className={`${card} space-y-4`}>
|
||||
<h2 className="text-xl font-bold">Activos, contratos e direitos declarados</h2>
|
||||
<h2 className="text-xl font-bold">
|
||||
Activos, contratos e direitos declarados
|
||||
</h2>
|
||||
<p>
|
||||
Registe separadamente cada elemento. Todos ficam pendentes de verificação; a
|
||||
declaração não confirma titularidade, validade ou transmissibilidade. Não use este
|
||||
formulário para anexar ficheiros.
|
||||
Registe separadamente cada elemento. Todos ficam pendentes de
|
||||
verificação; a declaração não confirma titularidade, validade ou
|
||||
transmissibilidade. Não use este formulário para anexar
|
||||
ficheiros.
|
||||
</p>
|
||||
{!objects.length && <p>Nenhum elemento registado.</p>}
|
||||
{objects.map((o) => (
|
||||
@@ -82,30 +87,36 @@ export default function BusinessObjects({
|
||||
<p>Pendente de verificação</p>
|
||||
<dl>
|
||||
{Object.entries(o.payload)
|
||||
.filter(([key, value]) => key !== "label" && value)
|
||||
.filter(([key, value]) => key !== 'label' && value)
|
||||
.map(([key, value]) => (
|
||||
<div key={key}>
|
||||
<dt className="font-semibold">
|
||||
{fields[key] ??
|
||||
(
|
||||
{
|
||||
area_unit: "Unidade da área",
|
||||
value_kind: "Natureza do valor",
|
||||
contract_type: "Tipo de contrato",
|
||||
area_unit:
|
||||
'Unidade da área',
|
||||
value_kind:
|
||||
'Natureza do valor',
|
||||
contract_type:
|
||||
'Tipo de contrato',
|
||||
} as Record<string, string>
|
||||
)[key] ??
|
||||
key}
|
||||
</dt>
|
||||
<dd className="break-words">
|
||||
{key === "value_kind"
|
||||
{key === 'value_kind'
|
||||
? ((
|
||||
{
|
||||
asking: "Pedido",
|
||||
indicative: "Indicativo",
|
||||
appraised: "Avaliado — declaração pendente",
|
||||
proposed: "Proposto",
|
||||
negotiated: "Negociado — declaração pendente",
|
||||
confirmed: "Confirmado — declaração pendente",
|
||||
asking: 'Pedido',
|
||||
indicative: 'Indicativo',
|
||||
appraised:
|
||||
'Avaliado — declaração pendente',
|
||||
proposed: 'Proposto',
|
||||
negotiated:
|
||||
'Negociado — declaração pendente',
|
||||
confirmed:
|
||||
'Confirmado — declaração pendente',
|
||||
} as Record<string, string>
|
||||
)[value] ?? value)
|
||||
: value}
|
||||
@@ -121,7 +132,7 @@ export default function BusinessObjects({
|
||||
setObjectId(o.id);
|
||||
setKind(o.kind);
|
||||
setPayload(o.payload);
|
||||
setReason("");
|
||||
setReason('');
|
||||
}}
|
||||
>
|
||||
Editar elemento
|
||||
@@ -135,12 +146,12 @@ export default function BusinessObjects({
|
||||
onSubmit={async (e) => {
|
||||
e.preventDefault();
|
||||
setBusy(true);
|
||||
setError("");
|
||||
setError('');
|
||||
try {
|
||||
await api(
|
||||
`/api/v1/existing-business/listings/${businessId}/objects${objectId ? `/${objectId}` : ""}`,
|
||||
`/api/v1/existing-business/listings/${businessId}/objects${objectId ? `/${objectId}` : ''}`,
|
||||
{
|
||||
...(objectId ? { _method: "PUT" } : {}),
|
||||
...(objectId ? { _method: 'PUT' } : {}),
|
||||
kind,
|
||||
payload,
|
||||
reason,
|
||||
@@ -152,7 +163,7 @@ export default function BusinessObjects({
|
||||
setError(
|
||||
err instanceof Error
|
||||
? err.message
|
||||
: "Não foi possível guardar o elemento.",
|
||||
: 'Não foi possível guardar o elemento.',
|
||||
);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
@@ -160,7 +171,9 @@ export default function BusinessObjects({
|
||||
}}
|
||||
>
|
||||
<h3 className="font-bold">
|
||||
{objectId ? "Editar elemento reservado" : "Acrescentar elemento reservado"}
|
||||
{objectId
|
||||
? 'Editar elemento reservado'
|
||||
: 'Acrescentar elemento reservado'}
|
||||
</h3>
|
||||
<Field label="Natureza">
|
||||
<select
|
||||
@@ -177,30 +190,65 @@ export default function BusinessObjects({
|
||||
</select>
|
||||
</Field>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{Object.entries(fields).map(([key, label]) => (
|
||||
<Field key={key} label={label}>
|
||||
<input
|
||||
className={input}
|
||||
type={key.startsWith("valid_") ? "date" : "text"}
|
||||
value={payload[key] ?? ""}
|
||||
maxLength={key === "label" ? 200 : 2000}
|
||||
required={key === "label" || key === "source_reference"}
|
||||
onChange={(e) =>
|
||||
setPayload({ ...payload, [key]: e.target.value })
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
))}
|
||||
{Object.entries(fields)
|
||||
.filter(([key]) => key !== 'resource_status')
|
||||
.map(([key, label]) => (
|
||||
<Field key={key} label={label}>
|
||||
<input
|
||||
className={input}
|
||||
type={
|
||||
key.startsWith('valid_')
|
||||
? 'date'
|
||||
: 'text'
|
||||
}
|
||||
value={payload[key] ?? ''}
|
||||
maxLength={key === 'label' ? 200 : 2000}
|
||||
required={
|
||||
key === 'label' ||
|
||||
key === 'source_reference'
|
||||
}
|
||||
onChange={(e) =>
|
||||
setPayload({
|
||||
...payload,
|
||||
[key]: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
))}
|
||||
<Field label={fields.resource_status}>
|
||||
<select
|
||||
className={input}
|
||||
value={payload.resource_status ?? ''}
|
||||
onChange={(e) =>
|
||||
setPayload({
|
||||
...payload,
|
||||
resource_status: e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">Por confirmar</option>
|
||||
<option value="available">Disponível</option>
|
||||
<option value="contracted">Contratado</option>
|
||||
<option value="planned">Previsto</option>
|
||||
<option value="unconfirmed">
|
||||
Por confirmar
|
||||
</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Unidade da área">
|
||||
<select
|
||||
className={input}
|
||||
value={payload.area_unit ?? ""}
|
||||
value={payload.area_unit ?? ''}
|
||||
onChange={(e) =>
|
||||
setPayload({ ...payload, area_unit: e.target.value })
|
||||
setPayload({
|
||||
...payload,
|
||||
area_unit: e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">Não indicada</option>
|
||||
{["m2", "ha", "km2"].map((x) => (
|
||||
{['m2', 'ha', 'km2'].map((x) => (
|
||||
<option key={x}>{x}</option>
|
||||
))}
|
||||
</select>
|
||||
@@ -208,19 +256,25 @@ export default function BusinessObjects({
|
||||
<Field label="Natureza do valor">
|
||||
<select
|
||||
className={input}
|
||||
value={payload.value_kind ?? ""}
|
||||
value={payload.value_kind ?? ''}
|
||||
onChange={(e) =>
|
||||
setPayload({ ...payload, value_kind: e.target.value })
|
||||
setPayload({
|
||||
...payload,
|
||||
value_kind: e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">Não indicada</option>
|
||||
{Object.entries({
|
||||
asking: "Pedido",
|
||||
indicative: "Indicativo",
|
||||
appraised: "Avaliado (declaração por verificar)",
|
||||
proposed: "Proposto",
|
||||
negotiated: "Negociado (declaração por verificar)",
|
||||
confirmed: "Confirmado (declaração por verificar)",
|
||||
asking: 'Pedido',
|
||||
indicative: 'Indicativo',
|
||||
appraised:
|
||||
'Avaliado (declaração por verificar)',
|
||||
proposed: 'Proposto',
|
||||
negotiated:
|
||||
'Negociado (declaração por verificar)',
|
||||
confirmed:
|
||||
'Confirmado (declaração por verificar)',
|
||||
}).map(([key, label]) => (
|
||||
<option key={key} value={key}>
|
||||
{label}
|
||||
@@ -231,19 +285,22 @@ export default function BusinessObjects({
|
||||
<Field label="Tipo de contrato">
|
||||
<select
|
||||
className={input}
|
||||
value={payload.contract_type ?? ""}
|
||||
value={payload.contract_type ?? ''}
|
||||
onChange={(e) =>
|
||||
setPayload({ ...payload, contract_type: e.target.value })
|
||||
setPayload({
|
||||
...payload,
|
||||
contract_type: e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">Não indicado</option>
|
||||
{Object.entries({
|
||||
purchase: "Compra",
|
||||
sale: "Venda",
|
||||
lease: "Arrendamento",
|
||||
operation: "Exploração",
|
||||
management: "Gestão",
|
||||
other: "Outro",
|
||||
purchase: 'Compra',
|
||||
sale: 'Venda',
|
||||
lease: 'Arrendamento',
|
||||
operation: 'Exploração',
|
||||
management: 'Gestão',
|
||||
other: 'Outro',
|
||||
}).map(([key, label]) => (
|
||||
<option key={key} value={key}>
|
||||
{label}
|
||||
@@ -264,7 +321,7 @@ export default function BusinessObjects({
|
||||
</Field>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
<button className={button} disabled={busy}>
|
||||
{busy ? "A guardar…" : "Guardar elemento reservado"}
|
||||
{busy ? 'A guardar…' : 'Guardar elemento reservado'}
|
||||
</button>
|
||||
{objectId && (
|
||||
<button
|
||||
@@ -273,7 +330,7 @@ export default function BusinessObjects({
|
||||
onClick={() => {
|
||||
setObjectId(null);
|
||||
setPayload({});
|
||||
setReason("");
|
||||
setReason('');
|
||||
}}
|
||||
>
|
||||
Cancelar edição
|
||||
|
||||
@@ -7,10 +7,10 @@ type Business = {
|
||||
province?: string | null; district?: string | null; locality?: string | null; sector?: { name: string; slug: string } | null;
|
||||
};
|
||||
|
||||
export default function BusinessOpportunity({ record }: { record: Business }) {
|
||||
export default function BusinessOpportunity({ record, returnUrl = "/negocios", interestUrl = `/negocios/${record.slug}/manifestar-interesse` }: { record: Business; returnUrl?: string; interestUrl?: string }) {
|
||||
return (
|
||||
<Frame title={record.title}>
|
||||
<Link href="/negocios" className="underline">Voltar às oportunidades</Link>
|
||||
<Link href={returnUrl} className="underline">Voltar às oportunidades</Link>
|
||||
<section className={`${card} space-y-4`}>
|
||||
<p>{[record.sector?.name, record.stage, record.activity_code].filter(Boolean).join(" · ")}</p>
|
||||
{(record.province || record.district || record.locality) && <p>{[record.locality, record.district, record.province].filter(Boolean).join(", ")}</p>}
|
||||
@@ -18,7 +18,7 @@ export default function BusinessOpportunity({ record }: { record: Business }) {
|
||||
{record.available_percentage && <p>Participação indicada: {record.available_percentage}%</p>}
|
||||
{record.objective && <div><h2 className="font-bold">Objectivo</h2><p className="whitespace-pre-wrap">{record.objective}</p></div>}
|
||||
<p className="text-sm">A publicação não constitui garantia de titularidade, avaliação, transmissibilidade ou retorno.</p>
|
||||
<Link className={button} href={`/negocios/${record.slug}/manifestar-interesse`}>Manifestar interesse</Link>
|
||||
<Link className={button} href={interestUrl}>Manifestar interesse</Link>
|
||||
</section>
|
||||
</Frame>
|
||||
);
|
||||
|
||||
@@ -15,6 +15,7 @@ export type Business = {
|
||||
amount_max?: string | null;
|
||||
available_percentage?: string | null;
|
||||
funds_use?: string | null;
|
||||
territory_paths?: string[][];
|
||||
submitted_at?: string | null;
|
||||
published_at?: string | null;
|
||||
expires_at?: string | null;
|
||||
@@ -31,43 +32,48 @@ export type Business = {
|
||||
};
|
||||
};
|
||||
export const businessStates: Record<string, string> = {
|
||||
draft: "Rascunho",
|
||||
submitted: "Submetido",
|
||||
in_review: "Em revisão",
|
||||
needs_information: "Pendente de informação",
|
||||
withdrawn: "Retirado",
|
||||
triage: "Triagem",
|
||||
information_pending: "Informação pendente",
|
||||
review: "Em revisão",
|
||||
approval_l1: "Aprovação nível 1",
|
||||
approval_l2: "Aprovação nível 2",
|
||||
approved: "Aprovado",
|
||||
published: "Publicado",
|
||||
suspended: "Suspenso",
|
||||
rejected: "Rejeitado",
|
||||
cancelled: "Cancelado",
|
||||
archived: "Arquivado",
|
||||
draft: 'Rascunho',
|
||||
submitted: 'Submetido',
|
||||
in_review: 'Em revisão',
|
||||
needs_information: 'Pendente de informação',
|
||||
withdrawn: 'Retirado',
|
||||
triage: 'Triagem',
|
||||
information_pending: 'Informação pendente',
|
||||
review: 'Em revisão',
|
||||
approval_l1: 'Aprovação nível 1',
|
||||
approval_l2: 'Aprovação nível 2',
|
||||
approved: 'Aprovado',
|
||||
published: 'Publicado',
|
||||
suspended: 'Suspenso',
|
||||
rejected: 'Rejeitado',
|
||||
cancelled: 'Cancelado',
|
||||
archived: 'Arquivado',
|
||||
};
|
||||
export const businessModalities: Record<string, string> = {
|
||||
company_sale: "Venda da empresa",
|
||||
participation_sale: "Venda de participação",
|
||||
capital_increase: "Aumento de capital",
|
||||
financial_investor: "Investidor financeiro",
|
||||
strategic_partner: "Sócio estratégico",
|
||||
buyer_search: "Procura de comprador",
|
||||
position_assignment: "Cessão de posição",
|
||||
franchise: "Franchising",
|
||||
asset_sale: "Venda de activos",
|
||||
asset_lease: "Arrendamento de activos",
|
||||
business_unit_transfer: "Transferência de unidade de negócio",
|
||||
joint_venture: "Joint venture",
|
||||
succession: "Sucessão empresarial",
|
||||
recovery: "Recuperação",
|
||||
expansion: "Expansão",
|
||||
internationalization: "Internacionalização",
|
||||
real_estate: "Imobiliário",
|
||||
agricultural_investment: "Investimento agrícola",
|
||||
land_right: "Direito fundiário",
|
||||
mining_license: "Licença mineira",
|
||||
forestry_license: "Licença florestal",
|
||||
company_sale: 'Venda da empresa',
|
||||
participation_sale: 'Venda de participação',
|
||||
capital_increase: 'Aumento de capital',
|
||||
financial_investor: 'Investidor financeiro',
|
||||
strategic_partner: 'Sócio estratégico',
|
||||
buyer_search: 'Procura de comprador',
|
||||
position_assignment: 'Cessão de posição',
|
||||
franchise: 'Franchising',
|
||||
asset_sale: 'Venda de activos',
|
||||
asset_lease: 'Arrendamento de activos',
|
||||
business_unit_transfer: 'Transferência de unidade de negócio',
|
||||
joint_venture: 'Joint venture',
|
||||
succession: 'Sucessão empresarial',
|
||||
recovery: 'Recuperação',
|
||||
expansion: 'Expansão',
|
||||
internationalization: 'Internacionalização',
|
||||
real_estate: 'Imobiliário',
|
||||
agricultural_investment: 'Investimento agrícola',
|
||||
land_right: 'Direito fundiário',
|
||||
mining_license: 'Licença mineira',
|
||||
forestry_license: 'Licença florestal',
|
||||
investment_project: 'Projecto de investimento',
|
||||
business_partnership: 'Parceria empresarial',
|
||||
financing_request: 'Procura de financiamento',
|
||||
concession_opportunity: 'Concessão',
|
||||
supply_opportunity: 'Oportunidade de fornecimento',
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,6 +51,7 @@ export default function Catalogue({
|
||||
district_id: String(filters.district_id ?? ""),
|
||||
admin_post_id: String(filters.admin_post_id ?? ""),
|
||||
locality_id: String(filters.locality_id ?? ""),
|
||||
include_national: Boolean(filters.include_national && filters.include_national !== "0"),
|
||||
cluster_id: String(filters.cluster_id ?? ""),
|
||||
zee_id: String(filters.zee_id ?? ""),
|
||||
zfi_id: String(filters.zfi_id ?? ""),
|
||||
@@ -90,7 +91,7 @@ export default function Catalogue({
|
||||
lastRequest.current = draftFilterKey;
|
||||
router.get(
|
||||
catalogueUrl,
|
||||
{ ...data, education: data.education ? 1 : 0 },
|
||||
{ ...data, education: data.education ? 1 : 0, include_national: data.include_national ? 1 : 0 },
|
||||
{
|
||||
preserveState: true,
|
||||
preserveScroll: true,
|
||||
@@ -201,11 +202,19 @@ export default function Catalogue({
|
||||
<Link className={card} href={dimensionUrl("zfi")}>
|
||||
Por ZFI
|
||||
</Link>
|
||||
<Link className={card} href="/zonas?category=zee">Fichas de ZEE</Link>
|
||||
<Link className={card} href="/zonas?category=zfi">Fichas de ZFI</Link>
|
||||
<Link className={card} href="/zonas?category=industrial_park">Parques industriais</Link>
|
||||
<Link className={card} href="/carteira?kind=project">Projectos âncora documentados</Link>
|
||||
<Link className={card} href="/negocios">Negócios e participações publicados</Link>
|
||||
</nav>
|
||||
<p>
|
||||
Combine contexto territorial, dimensão e necessidades. As fichas documentais e as
|
||||
oportunidades mantêm a sua origem e natureza.
|
||||
</p>
|
||||
<p className={card}>
|
||||
Negócios existentes, participações, imóveis e activos só surgem como anúncio depois de revisão e publicação expressa. A pesquisa de negócios é um catálogo separado; ausência de resultados não confirma inexistência do activo. As referências governamentais da carteira são separadas de anúncios privados.
|
||||
</p>
|
||||
<form
|
||||
className={card + " space-y-4"}
|
||||
onSubmit={(e) => {
|
||||
@@ -213,97 +222,11 @@ export default function Catalogue({
|
||||
setPoints(null);
|
||||
setComparison([]);
|
||||
setSelected([]);
|
||||
form.transform((data) => ({ ...data, education: data.education ? 1 : 0 }));
|
||||
form.transform((data) => ({ ...data, education: data.education ? 1 : 0, include_national: data.include_national ? 1 : 0 }));
|
||||
form.get(catalogueUrl, { preserveState: true });
|
||||
}}
|
||||
>
|
||||
<Field label="Pesquisar oportunidades">
|
||||
<input
|
||||
className={input}
|
||||
value={form.data.q}
|
||||
onChange={(e) => form.setData("q", e.target.value)}
|
||||
autoComplete="off"
|
||||
aria-describedby="search-suggestions"
|
||||
/>
|
||||
</Field>
|
||||
{suggestions.length > 0 && (
|
||||
<ul
|
||||
id="search-suggestions"
|
||||
aria-label="Sugestões de pesquisa"
|
||||
className="space-y-2"
|
||||
>
|
||||
{suggestions.map((s) => (
|
||||
<li key={s.slug}>
|
||||
<Link href={`/oportunidades/${s.slug}`} className="underline">
|
||||
{s.title}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
{(
|
||||
[
|
||||
["zee_id", "zee", "ZEE"],
|
||||
["zfi_id", "zfi", "ZFI"],
|
||||
["park_id", "industrial_park", "Parque industrial"],
|
||||
] as const
|
||||
).map(([field, category, label]) => (
|
||||
<Field key={field} label={label}>
|
||||
<select
|
||||
className={input}
|
||||
value={form.data[field]}
|
||||
onChange={(e) => form.setData(field, e.target.value)}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{(references.zones ?? [])
|
||||
.filter((z) => z.category === category)
|
||||
.map((z) => (
|
||||
<option key={z.id} value={z.id}>
|
||||
{z.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
))}
|
||||
{(["clusters", "corridors", "projects"] as const).map((group, i) => {
|
||||
const key = (
|
||||
["cluster_id", "corridor_id", "project_id", "geo_location_id"] as const
|
||||
)[i];
|
||||
return (
|
||||
<Field
|
||||
key={group}
|
||||
label={["Cluster", "Corredor", "Projecto âncora", "Localização"][i]}
|
||||
>
|
||||
<select
|
||||
className={input}
|
||||
value={form.data[key]}
|
||||
onChange={(e) => form.setData(key, e.target.value)}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{references[group].map((r) => (
|
||||
<option value={r.id} key={r.id}>
|
||||
{r.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
);
|
||||
})}
|
||||
<Field label="Sector">
|
||||
<select
|
||||
className={input}
|
||||
value={form.data.sector}
|
||||
onChange={(e) => form.setData("sector", e.target.value)}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{references.sectors.map((s) => (
|
||||
<option key={s.id} value={s.slug}>
|
||||
{s.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<section aria-label="Localização da oportunidade" className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
{(["province_id", "district_id", "admin_post_id", "locality_id"] as const).map(
|
||||
(key, index) => (
|
||||
<TerritoryLevel
|
||||
@@ -313,10 +236,7 @@ export default function Catalogue({
|
||||
selected={territoryPath[index]}
|
||||
endpoint="/api/v1/catalogs/jurisdictions"
|
||||
onChange={(value) => {
|
||||
const path = [
|
||||
...territoryPath.slice(0, index),
|
||||
...(value ? [value] : []),
|
||||
];
|
||||
const path = [...territoryPath.slice(0, index), ...(value ? [value] : [])];
|
||||
setTerritoryPath(path);
|
||||
form.setData((data) => ({
|
||||
...data,
|
||||
@@ -327,11 +247,68 @@ export default function Catalogue({
|
||||
district_id: path[1]?.id ?? "",
|
||||
admin_post_id: path[2]?.id ?? "",
|
||||
locality_id: path[3]?.id ?? "",
|
||||
zee_id: "",
|
||||
zfi_id: "",
|
||||
park_id: "",
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
),
|
||||
)}
|
||||
</section>
|
||||
<Field label="Pesquisar oportunidades">
|
||||
<input
|
||||
className={input}
|
||||
value={form.data.q}
|
||||
onChange={(e) => form.setData("q", e.target.value)}
|
||||
autoComplete="off"
|
||||
aria-describedby="search-suggestions"
|
||||
/>
|
||||
</Field>
|
||||
{suggestions.length > 0 && (
|
||||
<ul id="search-suggestions" aria-label="Sugestões de pesquisa" className="space-y-2">
|
||||
{suggestions.map((s) => (
|
||||
<li key={s.slug}>
|
||||
<Link href={`/oportunidades/${s.slug}`} className="underline">{s.title}</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
{([
|
||||
["zee_id", "zee", "ZEE"],
|
||||
["zfi_id", "zfi", "ZFI"],
|
||||
["park_id", "industrial_park", "Parque industrial"],
|
||||
] as const).map(([field, category, label]) => (
|
||||
<Field key={field} label={label}>
|
||||
<select className={input} value={form.data[field]} onChange={(e) => form.setData(field, e.target.value)}>
|
||||
<option value="">Todos</option>
|
||||
{(references.zones ?? []).filter((zone) => zone.category === category).map((zone) => (
|
||||
<option key={zone.id} value={zone.id}>{zone.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
))}
|
||||
{(["clusters", "corridors", "projects"] as const).map((group, index) => {
|
||||
const key = (["cluster_id", "corridor_id", "project_id"] as const)[index];
|
||||
const label = (["Cluster", "Corredor", "Projecto âncora"] as const)[index];
|
||||
return (
|
||||
<Field key={group} label={label}>
|
||||
<select className={input} value={form.data[key]} onChange={(e) => form.setData(key, e.target.value)}>
|
||||
<option value="">Todos</option>
|
||||
{references[group].map((item) => <option value={item.id} key={item.id}>{item.name}</option>)}
|
||||
</select>
|
||||
</Field>
|
||||
);
|
||||
})}
|
||||
<Field label="Sector">
|
||||
<select className={input} value={form.data.sector} onChange={(e) => form.setData("sector", e.target.value)}>
|
||||
<option value="">Todos</option>
|
||||
{references.sectors.map((sector) => <option key={sector.id} value={sector.slug}>{sector.name}</option>)}
|
||||
</select>
|
||||
</Field>
|
||||
</div>
|
||||
<section className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<Field label="Estado de preparação">
|
||||
<select
|
||||
className={input}
|
||||
@@ -387,7 +364,7 @@ export default function Catalogue({
|
||||
onChange={(e) => form.setData("before", e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
</section>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -396,6 +373,11 @@ export default function Catalogue({
|
||||
/>
|
||||
Apenas oportunidades na educação
|
||||
</label>
|
||||
<label className="flex gap-2">
|
||||
<input type="checkbox" checked={form.data.include_national}
|
||||
onChange={(e) => form.setData("include_national", e.target.checked)} />
|
||||
Incluir âmbito nacional
|
||||
</label>
|
||||
<details>
|
||||
<summary className="cursor-pointer font-semibold">
|
||||
Subsector, educação, infraestruturas, competências e apoios
|
||||
@@ -467,8 +449,50 @@ export default function Catalogue({
|
||||
</p>
|
||||
))}
|
||||
</form>
|
||||
{(territoryPath.length > 0 || form.data.q || form.data.dimension || form.data.sector || form.data.cluster_id || form.data.corridor_id || form.data.project_id || form.data.geo_location_id || form.data.zee_id || form.data.zfi_id || form.data.park_id || form.data.include_national || form.data.education || form.data.maturity_level || form.data.min_amount || form.data.max_amount || form.data.currency || form.data.before || form.data.facets.length > 0) && (
|
||||
<section aria-label="Filtros activos" className="flex flex-wrap items-center gap-2">
|
||||
<strong>Filtros activos:</strong>
|
||||
{territoryPath.map((node, index) => <span key={node.id} className="rounded border px-2 py-1">{node.name} <button type="button" aria-label={`Remover localização ${node.name}`} onClick={() => {
|
||||
const path = territoryPath.slice(0, index);
|
||||
setTerritoryPath(path);
|
||||
form.setData((data) => ({ ...data, province_id: path[0]?.id ?? "", district_id: path[1]?.id ?? "", admin_post_id: path[2]?.id ?? "", locality_id: path[3]?.id ?? "", province: "", district: "", geo_location_id: "" }));
|
||||
}}>×</button></span>)}
|
||||
{form.data.sector && <span className="rounded border px-2 py-1">Sector: {references.sectors.find((s) => s.slug === form.data.sector)?.name ?? form.data.sector}</span>}
|
||||
{form.data.cluster_id && <span className="rounded border px-2 py-1">Cluster: {references.clusters.find((v) => v.id === form.data.cluster_id)?.name} <button type="button" aria-label="Remover filtro Cluster" onClick={() => form.setData("cluster_id", "")}>×</button></span>}
|
||||
{form.data.corridor_id && <span className="rounded border px-2 py-1">Corredor: {references.corridors.find((v) => v.id === form.data.corridor_id)?.name} <button type="button" aria-label="Remover filtro Corredor" onClick={() => form.setData("corridor_id", "")}>×</button></span>}
|
||||
{form.data.project_id && <span className="rounded border px-2 py-1">Projecto: {references.projects.find((v) => v.id === form.data.project_id)?.name} <button type="button" aria-label="Remover filtro Projecto" onClick={() => form.setData("project_id", "")}>×</button></span>}
|
||||
{form.data.q && <span className="rounded border px-2 py-1">Pesquisa: {form.data.q} <button type="button" aria-label="Remover pesquisa" onClick={() => form.setData("q", "")}>×</button></span>}
|
||||
{form.data.dimension && <span className="rounded border px-2 py-1">Dimensão: {form.data.dimension} <button type="button" aria-label="Remover dimensão" onClick={() => form.setData("dimension", "")}>×</button></span>}
|
||||
{form.data.geo_location_id && <span className="rounded border px-2 py-1">Localização adicional: {references.locations.find((v) => v.id === form.data.geo_location_id)?.name ?? "seleccionada"} <button type="button" aria-label="Remover localização adicional" onClick={() => form.setData("geo_location_id", "")}>×</button></span>}
|
||||
{form.data.zee_id && <span className="rounded border px-2 py-1">ZEE: {references.zones?.find((z) => z.id === form.data.zee_id)?.name ?? "seleccionada"} <button type="button" aria-label="Remover filtro ZEE" onClick={() => form.setData("zee_id", "")}>×</button></span>}
|
||||
{form.data.zfi_id && <span className="rounded border px-2 py-1">ZFI: {references.zones?.find((z) => z.id === form.data.zfi_id)?.name ?? "seleccionada"} <button type="button" aria-label="Remover filtro ZFI" onClick={() => form.setData("zfi_id", "")}>×</button></span>}
|
||||
{form.data.park_id && <span className="rounded border px-2 py-1">Parque: {references.zones?.find((z) => z.id === form.data.park_id)?.name ?? "seleccionado"} <button type="button" aria-label="Remover filtro parque" onClick={() => form.setData("park_id", "")}>×</button></span>}
|
||||
{form.data.education && <span className="rounded border px-2 py-1">Educação <button type="button" aria-label="Remover filtro de educação" onClick={() => form.setData("education", false)}>×</button></span>}
|
||||
{form.data.maturity_level && <span className="rounded border px-2 py-1">Maturidade: {form.data.maturity_level} <button type="button" aria-label="Remover maturidade" onClick={() => form.setData("maturity_level", "")}>×</button></span>}
|
||||
{(form.data.min_amount || form.data.max_amount) && <span className="rounded border px-2 py-1">Montante: {form.data.min_amount || "sem mínimo"}–{form.data.max_amount || "sem máximo"} {form.data.currency} <button type="button" aria-label="Remover intervalo de montante" onClick={() => form.setData((data) => ({ ...data, min_amount: "", max_amount: "", currency: "" }))}>×</button></span>}
|
||||
{form.data.currency && !form.data.min_amount && !form.data.max_amount && <span className="rounded border px-2 py-1">Moeda: {form.data.currency} <button type="button" aria-label="Remover moeda" onClick={() => form.setData("currency", "")}>×</button></span>}
|
||||
{form.data.before && <span className="rounded border px-2 py-1">Data até: {form.data.before} <button type="button" aria-label="Remover data-alvo" onClick={() => form.setData("before", "")}>×</button></span>}
|
||||
{form.data.facets.map((id) => {
|
||||
const option = references.options.find((item) => item.id === id);
|
||||
return <span key={id} className="rounded border px-2 py-1">{option?.label ?? `Opção ${id}`} <button type="button" aria-label={`Remover filtro ${option?.label ?? id}`} onClick={() => form.setData("facets", form.data.facets.filter((value) => value !== id))}>×</button></span>;
|
||||
})}
|
||||
{form.data.include_national && <span className="rounded border px-2 py-1">Âmbito nacional incluído</span>}
|
||||
{territoryPath.length > 0 && <button type="button" className="underline" onClick={() => {
|
||||
setTerritoryPath([]);
|
||||
form.setData((data) => ({ ...data, province_id: "", district_id: "", admin_post_id: "", locality_id: "", province: "", district: "", geo_location_id: "" }));
|
||||
}}>Remover localização</button>}
|
||||
{form.data.sector && <button type="button" className="underline" onClick={() => form.setData("sector", "")}>Remover sector</button>}
|
||||
{form.data.include_national && <button type="button" className="underline" onClick={() => form.setData("include_national", false)}>Remover âmbito nacional</button>}
|
||||
</section>
|
||||
)}
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<p role="status">{results.total} oportunidades publicadas</p>
|
||||
{results.total === 0 && (form.data.province_id || form.data.district_id || form.data.admin_post_id || form.data.locality_id) && (
|
||||
<button type="button" className="underline" onClick={() => {
|
||||
setTerritoryPath([]);
|
||||
form.setData((data) => ({ ...data, province_id: "", district_id: "", admin_post_id: "", locality_id: "", province: "", district: "", geo_location_id: "" }));
|
||||
}}>Alargar pesquisa (remover localização)</button>
|
||||
)}
|
||||
{["grid", "list", "map", "combined"].map((value, i) => (
|
||||
<button
|
||||
key={value}
|
||||
@@ -531,13 +555,18 @@ export default function Catalogue({
|
||||
{r.sector?.name} · {r.province || "Localização não indicada"}
|
||||
</p>
|
||||
<h2 className="text-xl font-bold">
|
||||
<Link href={`/oportunidades/${r.slug}`}>{r.title}</Link>
|
||||
<Link href={`/oportunidades/${r.slug}${query() ? `?${query()}` : ""}`}>{r.title}</Link>
|
||||
</h2>
|
||||
{!r.last_validated_at && (
|
||||
<p className="rounded border border-amber-700 bg-amber-50 p-3 text-sm">
|
||||
Esta ficha não regista data de validação documental. Confirme a origem e as condições antes de agir.
|
||||
</p>
|
||||
)}
|
||||
<p>{r.summary}</p>
|
||||
<p className="font-semibold">{money(r)}</p>
|
||||
<p>{r.maturity_label}</p>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
<Link className="underline" href={`/oportunidades/${r.slug}`}>
|
||||
<Link className="underline" href={`/oportunidades/${r.slug}${query() ? `?${query()}` : ""}`}>
|
||||
Ver ficha
|
||||
</Link>
|
||||
<button
|
||||
|
||||
@@ -7,18 +7,26 @@ export default function Detail({
|
||||
record: r,
|
||||
context: c,
|
||||
zone_origin,
|
||||
returnUrl = "/oportunidades",
|
||||
}: {
|
||||
record: Opportunity;
|
||||
context: Context;
|
||||
zone_origin?: { id: string; name: string } | null;
|
||||
returnUrl?: string;
|
||||
}) {
|
||||
const { auth } = usePage<{ auth: { user: unknown } }>().props;
|
||||
const [sharing, setSharing] = useState("");
|
||||
return (
|
||||
<Frame title={r.title}>
|
||||
<Link href={returnUrl} className="underline">Voltar à pesquisa</Link>
|
||||
<p>
|
||||
{r.reference} · {r.sector?.name} · {r.province} {r.district}
|
||||
</p>
|
||||
{!r.last_validated_at && (
|
||||
<p className="rounded border border-amber-700 bg-amber-50 p-4">
|
||||
Esta ficha não regista data de validação documental. Confirme a origem e as condições antes de agir. Preparar uma manifestação expressa interesse; não confirma a oferta nem representa aprovação.
|
||||
</p>
|
||||
)}
|
||||
<p className="text-xl">{r.summary}</p>
|
||||
<InvestmentMapPanel filters={{ opportunity_id: r.id }} />
|
||||
{c.primary_territory_path && c.primary_territory_path.length > 0 && (
|
||||
|
||||
@@ -38,6 +38,7 @@ export type Opportunity = {
|
||||
expected_impact: string | null;
|
||||
financing_modality: string | null;
|
||||
status: string;
|
||||
last_validated_at?: string | null;
|
||||
};
|
||||
export type Context = {
|
||||
primary_territory_path?: { id: string; name: string; location_type: string }[];
|
||||
@@ -118,15 +119,16 @@ export async function api(url: string, body?: unknown) {
|
||||
.find((c) => c.startsWith("XSRF-TOKEN="))
|
||||
?.slice(11) ?? "",
|
||||
);
|
||||
const formData = typeof FormData !== "undefined" && body instanceof FormData;
|
||||
const response = await fetch(url, {
|
||||
method: body === undefined ? "GET" : "POST",
|
||||
credentials: "same-origin",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
...(formData ? {} : { "Content-Type": "application/json" }),
|
||||
"X-XSRF-TOKEN": token,
|
||||
},
|
||||
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
||||
...(body === undefined ? {} : { body: formData ? body : JSON.stringify(body) }),
|
||||
});
|
||||
const data = await response.json();
|
||||
if (!response.ok) throw new Error(data.message ?? "Não foi possível concluir a operação.");
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
import { router } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import { api, button, card, Field, input } from "./shared";
|
||||
|
||||
export type ZoneAttachment = {
|
||||
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;
|
||||
independent_review?: boolean;
|
||||
publicly_selected?: boolean;
|
||||
version_no?: number;
|
||||
file_name?: string;
|
||||
file_status?: string;
|
||||
document_id?: string;
|
||||
malware_scan_status?: 'pending' | 'scanning' | 'clean' | 'infected' | 'inconclusive' | 'failed';
|
||||
malware_failure_reason?: string | null;
|
||||
media_type: string;
|
||||
size_bytes: number | null;
|
||||
download_url: string;
|
||||
};
|
||||
|
||||
export default function ZoneAttachments({
|
||||
zoneId,
|
||||
attachments,
|
||||
management,
|
||||
zonePublished,
|
||||
}: {
|
||||
zoneId: string;
|
||||
attachments: ZoneAttachment[];
|
||||
management: boolean;
|
||||
zonePublished: boolean;
|
||||
}) {
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [kind, setKind] = useState("legal_instrument");
|
||||
const [caption, setCaption] = useState("");
|
||||
const [source, setSource] = useState("");
|
||||
const [sourceDate, setSourceDate] = useState("");
|
||||
const [rights, setRights] = useState("pending");
|
||||
const [rightsBasis, setRightsBasis] = useState("");
|
||||
const [reviewChoices, setReviewChoices] = useState<Record<string, { rights: string; personal: string }>>({});
|
||||
const [reviewRightsBasis, setReviewRightsBasis] = useState<Record<string, string>>({});
|
||||
const [error, setError] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
async function send(url: string, payload: unknown) {
|
||||
setBusy(true);
|
||||
setError("");
|
||||
try {
|
||||
await api(url, payload);
|
||||
router.reload();
|
||||
} catch (failure) {
|
||||
setError(failure instanceof Error ? failure.message : "Não foi possível guardar o anexo.");
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<section className={card + " space-y-4"} aria-label="Anexos documentais da zona">
|
||||
<h2 className="text-xl font-bold">{management ? "Anexos documentais" : "Documentos e materiais publicados"}</h2>
|
||||
{management && <>
|
||||
<p>Os ficheiros ficam privados por defeito. A revisão é administrativa e não equivale a certificação. Só seleccione para divulgação ficheiros sem dados pessoais e com direitos de utilização esclarecidos.</p>
|
||||
<form className="grid gap-3 md:grid-cols-2" onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
if (!file) return;
|
||||
const data = new FormData();
|
||||
data.set("file", file);
|
||||
data.set("kind", kind);
|
||||
data.set("caption", caption);
|
||||
data.set("source_reference", source);
|
||||
if (sourceDate) data.set("source_date", sourceDate);
|
||||
data.set("rights_status", rights);
|
||||
if (rightsBasis) data.set("rights_basis", rightsBasis);
|
||||
void send(`/api/v2/investment/admin/zones/${zoneId}/attachments`, data).then(() => setFile(null));
|
||||
}}>
|
||||
<Field label="Ficheiro (PDF, JPEG, PNG ou WebP; máximo 20 MB)">
|
||||
<input className={input} type="file" accept="application/pdf,image/jpeg,image/png,image/webp" required onChange={(event) => setFile(event.target.files?.[0] ?? null)} />
|
||||
</Field>
|
||||
<Field label="Tipo do anexo"><select className={input} value={kind} onChange={(event) => setKind(event.target.value)}><option value="legal_instrument">Diploma</option><option value="map">Mapa</option><option value="photo">Fotografia</option><option value="study">Estudo</option><option value="other">Outro</option></select></Field>
|
||||
<Field label="Legenda ou título"><input className={input} required maxLength={255} value={caption} onChange={(event) => setCaption(event.target.value)} /></Field>
|
||||
<Field label="Origem exacta do ficheiro"><input className={input} required minLength={5} maxLength={2000} value={source} onChange={(event) => setSource(event.target.value)} /></Field>
|
||||
<Field label="Data da fonte, se conhecida"><input className={input} type="date" value={sourceDate} onChange={(event) => setSourceDate(event.target.value)} /></Field>
|
||||
<Field label="Direitos de utilização"><select className={input} value={rights} onChange={(event) => setRights(event.target.value)}><option value="pending">Por confirmar</option><option value="confirmed">Confirmados</option><option value="restricted">Restritos</option></select></Field>
|
||||
<Field label="Fundamento dos direitos (se confirmado)"><input className={input} maxLength={2000} value={rightsBasis} onChange={(event) => setRightsBasis(event.target.value)} /></Field>
|
||||
<button className={button} disabled={busy || !file || !caption.trim() || !source.trim()}>Carregar como privado</button>
|
||||
</form>
|
||||
</>}
|
||||
{error && <p role="alert">{error}</p>}
|
||||
{attachments.length === 0 && <p>Não existem anexos divulgados nesta zona.</p>}
|
||||
{attachments.map((item) => {
|
||||
const choice = reviewChoices[item.id] ?? { rights: item.rights_status ?? "pending", personal: item.personal_data_status ?? "unknown" };
|
||||
return <article key={item.id} className="space-y-2 rounded border p-3">
|
||||
<p className="font-semibold">{item.caption} · {item.kind}{management && item.file_name ? ` · ${item.file_name}` : ""}</p>
|
||||
<p className="text-sm">Origem: {item.source_reference}{item.source_date ? ` · ${item.source_date}` : ""}{management ? ` · ${item.review_status}` : ""}</p>
|
||||
{management && item.independent_review === false && <p className="text-sm">Revisão administrativa registada; não independente e não certificadora.</p>}
|
||||
{management && item.malware_scan_status === "pending" && <p role="status">A analisar o ficheiro.</p>}
|
||||
{management && item.malware_scan_status === "scanning" && <p role="status">A analisar o ficheiro.</p>}
|
||||
{management && item.malware_scan_status === "clean" && <p role="status">Análise concluída: nenhuma ameaça detectada. O ficheiro continua privado até à divulgação explícita.</p>}
|
||||
{management && item.malware_scan_status === "infected" && <p role="alert">Ficheiro bloqueado: ameaça detectada. Mantenha-o em quarentena e carregue uma versão substituta.</p>}
|
||||
{management && ["inconclusive", "failed"].includes(item.malware_scan_status ?? "") && <p role="alert">Não foi possível concluir a análise. O ficheiro permanece privado e indisponível para divulgação.{item.malware_failure_reason ? ` Motivo: ${item.malware_failure_reason}.` : ""}</p>}
|
||||
{management && item.document_id && ["pending", "inconclusive", "failed"].includes(item.malware_scan_status ?? "") && <button type="button" className={button} disabled={busy} onClick={() => void send(`/management/documents/${item.document_id}/malware/retry`, {})}>Tentar análise novamente</button>}
|
||||
{management && item.review_status !== "reviewed" && <div className="grid gap-2 md:grid-cols-2">
|
||||
<select className={input} aria-label={`Direitos de ${item.caption}`} value={choice.rights} onChange={(event) => setReviewChoices((current) => ({ ...current, [item.id]: { ...choice, rights: event.target.value } }))}><option value="pending">Direitos por confirmar</option><option value="confirmed">Direitos confirmados</option><option value="restricted">Direitos restritos</option></select>
|
||||
<select className={input} aria-label={`Dados pessoais de ${item.caption}`} value={choice.personal} onChange={(event) => setReviewChoices((current) => ({ ...current, [item.id]: { ...choice, personal: event.target.value } }))}><option value="unknown">Dados pessoais por verificar</option><option value="none">Sem dados pessoais</option><option value="present">Contém dados pessoais</option></select>
|
||||
<input className={input} aria-label={`Fundamento dos direitos de ${item.caption}`} placeholder="Fundamento dos direitos" maxLength={2000} value={reviewRightsBasis[item.id] ?? item.rights_basis ?? ""} onChange={(event) => setReviewRightsBasis((current) => ({ ...current, [item.id]: event.target.value }))} />
|
||||
<button type="button" className={button} disabled={busy || choice.personal === "unknown" || (choice.rights === "confirmed" && !(reviewRightsBasis[item.id] ?? item.rights_basis)?.trim())} onClick={() => void send(`/api/v2/investment/admin/zone-attachments/${item.id}/review`, { version_no: item.version_no, decision: "reviewed", personal_data_status: choice.personal, rights_status: choice.rights, rights_basis: reviewRightsBasis[item.id] ?? item.rights_basis })}>Registar revisão administrativa</button>
|
||||
<button type="button" className={button} disabled={busy} onClick={() => void send(`/api/v2/investment/admin/zone-attachments/${item.id}/review`, { version_no: item.version_no, decision: "rejected", personal_data_status: choice.personal, rights_status: choice.rights, rights_basis: reviewRightsBasis[item.id] ?? item.rights_basis })}>Registar como não divulgável</button>
|
||||
</div>}
|
||||
{item.media_type.startsWith("image/") && (!management || item.malware_scan_status === "clean") && <img className="max-h-96 rounded object-contain" src={item.download_url} alt={item.caption} />}
|
||||
{(!management || item.malware_scan_status === "clean") && <a className="underline" href={item.download_url}>Abrir ficheiro</a>}
|
||||
{management && item.review_status === "reviewed" && !item.publicly_selected && <button type="button" className={button} disabled={busy || !zonePublished || item.file_status !== "active" || item.rights_status !== "confirmed" || item.personal_data_status !== "none"} onClick={() => void send(`/api/v2/investment/admin/zone-attachments/${item.id}/select-public`, { version_no: item.version_no })}>Seleccionar para divulgação</button>}
|
||||
{management && item.publicly_selected && <button type="button" className={button} disabled={busy} onClick={() => void send(`/api/v2/investment/admin/zone-attachments/${item.id}/withdraw-public`, { version_no: item.version_no })}>Retirar da divulgação</button>}
|
||||
</article>;
|
||||
})}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
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 ZoneRelations from "./zone-relations";
|
||||
import ZoneMap from "./zone-map";
|
||||
import ZoneAttachments from "./zone-attachments";
|
||||
import type { ZoneTargets } from "./zone-relations";
|
||||
|
||||
type Zone = {
|
||||
@@ -22,6 +24,19 @@ type Zone = {
|
||||
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?: unknown[];
|
||||
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;
|
||||
@@ -35,6 +50,33 @@ type Source = {
|
||||
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 }[];
|
||||
@@ -47,6 +89,7 @@ type Props = {
|
||||
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 }[];
|
||||
@@ -59,6 +102,13 @@ type Props = {
|
||||
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;
|
||||
@@ -75,20 +125,56 @@ function Editor({
|
||||
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 form = useForm({
|
||||
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 ?? "",
|
||||
@@ -132,8 +218,11 @@ function Editor({
|
||||
setBusy(true);
|
||||
setMessage("");
|
||||
try {
|
||||
const { area_components_json, source_evidence_json, ...base } = form.data;
|
||||
await api(`/api/v2/investment/admin/zones/${z.id}`, {
|
||||
...form.data,
|
||||
...base,
|
||||
area_components: JSON.parse(area_components_json),
|
||||
source_evidence: JSON.parse(source_evidence_json),
|
||||
_method: "PUT",
|
||||
});
|
||||
router.reload();
|
||||
@@ -175,6 +264,96 @@ function Editor({
|
||||
<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"],
|
||||
@@ -221,6 +400,36 @@ function Editor({
|
||||
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">Revisão independente</h2>
|
||||
<p>
|
||||
@@ -386,6 +595,14 @@ function Editor({
|
||||
) : (
|
||||
<>
|
||||
<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, index) => <li key={index}>{JSON.stringify(evidence)}</li>)}</ul></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>
|
||||
@@ -396,6 +613,7 @@ function Editor({
|
||||
</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>
|
||||
|
||||
@@ -10,14 +10,26 @@ type Zone = {
|
||||
category: string;
|
||||
description: string | null;
|
||||
province: string | null;
|
||||
district: string | null;
|
||||
version_no: number;
|
||||
publication_status: string;
|
||||
validation_status: string;
|
||||
territory_path?: { id: string; name: string; location_type: string }[];
|
||||
legal_regime?: string | null;
|
||||
operational_status?: string;
|
||||
development_status?: string;
|
||||
availability_status?: string;
|
||||
source_evidence?: { title: string; url: string; source_type: string; supports: string; source_date?: string | null }[];
|
||||
area_value?: string | null;
|
||||
area_unit?: string | null;
|
||||
activities?: { name: string; status: string }[];
|
||||
locations?: { id: string; name: string; location_type: string; scope_type: string }[];
|
||||
};
|
||||
export default function Zones({
|
||||
records,
|
||||
filters,
|
||||
management,
|
||||
zoneExtensionsAvailable = false,
|
||||
territorySelection = [],
|
||||
}: {
|
||||
records: {
|
||||
@@ -26,12 +38,20 @@ export default function Zones({
|
||||
next_page_url: string | null;
|
||||
prev_page_url: string | null;
|
||||
};
|
||||
filters: { q?: string; category?: string };
|
||||
filters: { q?: string; category?: string; physical_category?: string; legal_regime?: string; development_status?: string; availability_status?: string; activity?: string };
|
||||
management: boolean;
|
||||
zoneExtensionsAvailable?: boolean;
|
||||
territorySelection?: TerritoryOption[];
|
||||
}) {
|
||||
const [error, setError] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const exportParams = new URLSearchParams();
|
||||
for (const key of ["q", "category", "physical_category", "legal_regime", "development_status", "availability_status", "activity"] as const) {
|
||||
const value = filters[key];
|
||||
if (value) exportParams.set(key, value);
|
||||
}
|
||||
const territoryKeys: Record<string, string> = { province: "province_id", district: "district_id", admin_post: "admin_post_id", locality: "locality_id" };
|
||||
territorySelection.forEach((item) => { const key = territoryKeys[item.location_type]; if (key) exportParams.set(key, item.id); });
|
||||
return (
|
||||
<Frame
|
||||
title={management ? "Gestão de ZEE, ZFI e parques" : "ZEE, ZFI e parques industriais"}
|
||||
@@ -59,10 +79,34 @@ export default function Zones({
|
||||
<option value="industrial_park">Parque industrial</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Categoria física">
|
||||
<select className={input} name="physical_category" defaultValue={filters.physical_category ?? ""}>
|
||||
<option value="">Todas</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">ZFI</option><option value="economic_zone">ZEE</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Actividade documentada">
|
||||
<input className={input} name="activity" defaultValue={filters.activity} maxLength={120} />
|
||||
</Field>
|
||||
<Field label="Regime jurídico">
|
||||
<select className={input} name="legal_regime" defaultValue={filters.legal_regime ?? ""}>
|
||||
<option value="">Todos</option><option value="zee">ZEE</option><option value="zfi">ZFI</option><option value="general">Regime geral</option><option value="pending">Por confirmar</option>
|
||||
</select>
|
||||
</Field>
|
||||
{zoneExtensionsAvailable && <Field label="Desenvolvimento">
|
||||
<select className={input} name="development_status" defaultValue={filters.development_status ?? ""}>
|
||||
<option value="">Todos</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="unknown">Por confirmar</option>
|
||||
</select>
|
||||
</Field>}
|
||||
{zoneExtensionsAvailable && <Field label="Disponibilidade">
|
||||
<select className={input} name="availability_status" defaultValue={filters.availability_status ?? ""}>
|
||||
<option value="">Todas</option><option value="confirmed">Confirmada</option><option value="unavailable">Indisponível</option><option value="reported_unverified">Reportada, por verificar</option><option value="not_informed">Não informada</option>
|
||||
</select>
|
||||
</Field>}
|
||||
<TerritoryFields initial={territorySelection} />
|
||||
<button className={button}>Pesquisar</button>
|
||||
</form>
|
||||
<p role="status">{records.total} registos disponíveis</p>
|
||||
{!management && <a className="underline" href={`/api/v2/investment/zones/export.csv?${exportParams.toString()}`}>Exportar resultados filtrados (CSV)</a>}
|
||||
{!records.total && (
|
||||
<p className={card}>
|
||||
Sem registos disponíveis para estes filtros. As zonas aguardam cadastro e
|
||||
@@ -81,8 +125,15 @@ export default function Zones({
|
||||
</h2>
|
||||
<p>
|
||||
{zone.code} · {zone.category.toUpperCase()} ·{" "}
|
||||
{zone.province ?? "Localização por confirmar"}
|
||||
{[zone.district, zone.province].filter(Boolean).join(", ") || "Localização por confirmar"}
|
||||
</p>
|
||||
{zone.legal_regime && <p>Regime jurídico: {zone.legal_regime.toUpperCase()}</p>}
|
||||
{zoneExtensionsAvailable && zone.development_status && <p>Desenvolvimento: {zone.development_status.replaceAll("_", " ")}</p>}
|
||||
{zoneExtensionsAvailable && zone.availability_status && <p>Disponibilidade para instalação: {zone.availability_status.replaceAll("_", " ")}</p>}
|
||||
{zone.area_value && <p>Área indicada: {zone.area_value} {zone.area_unit}</p>}
|
||||
{zone.locations?.length ? <p>Abrangência: {zone.locations.map((location) => location.name).join(" · ")}</p> : null}
|
||||
{zone.activities?.length ? <p>Actividades: {zone.activities.map((activity) => `${activity.name} (${activity.status})`).join(" · ")}</p> : null}
|
||||
{!!zone.source_evidence?.length && <p>Fonte: {zone.source_evidence.map((source, index) => <span key={source.url}>{index > 0 ? " · " : ""}<a className="underline" href={source.url} target="_blank" rel="noreferrer">{source.title}</a>{source.source_date ? ` (${source.source_date})` : " (data da fonte não informada)"} — {source.supports}</span>)}</p>}
|
||||
<p>{zone.description}</p>
|
||||
<p>Validação: {zone.validation_status}</p>
|
||||
{management && (
|
||||
@@ -134,6 +185,64 @@ export default function Zones({
|
||||
<option value="industrial_park">Parque industrial</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Categoria física">
|
||||
<select name="physical_category" className={input} defaultValue="unknown">
|
||||
<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>}
|
||||
{zoneExtensionsAvailable && <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>
|
||||
</select>
|
||||
</Field>
|
||||
{zoneExtensionsAvailable && <Field label="Estado de desenvolvimento">
|
||||
<select name="development_status" className={input} defaultValue="unknown"><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 name="availability_status" className={input} defaultValue="not_informed"><option value="not_informed">Não informada</option><option value="confirmed">Confirmada por fonte</option><option value="unavailable">Indisponível</option><option value="reported_unverified">Reportada, por verificar</option></select>
|
||||
</Field>}
|
||||
<Field label="Regime jurídico">
|
||||
<select name="legal_regime" className={input} defaultValue="pending">
|
||||
<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="Área (valor) — se documentada">
|
||||
<input name="area_value" className={input} type="number" min="0" step="0.0001" />
|
||||
</Field>
|
||||
<Field label="Unidade da área">
|
||||
<select name="area_unit" className={input} defaultValue="">
|
||||
<option value="">Por confirmar</option><option value="ha">hectares (ha)</option><option value="km2">quilómetros quadrados (km²)</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Actividade documentada (opcional)">
|
||||
<input name="activity_name" className={input} maxLength={300} />
|
||||
</Field>
|
||||
<Field label="Estado da actividade">
|
||||
<select name="activity_status" className={input} defaultValue="potential">
|
||||
<option value="potential">Potencial referido pela fonte</option><option value="proposed">Proposta</option>
|
||||
<option value="authorized">Autorizada por documento</option><option value="conditional">Condicionada</option><option value="excluded">Excluída</option>
|
||||
</select>
|
||||
</Field>
|
||||
<Field label="Designações alternativas">
|
||||
<textarea name="aliases_text" className={input} rows={2} placeholder="Uma por linha" />
|
||||
</Field>
|
||||
<Field label="Localização histórica (se diferente da actual)">
|
||||
<input name="historical_name" className={input} maxLength={255} />
|
||||
</Field>
|
||||
<Field label="Distrito histórico">
|
||||
<input name="historical_district" className={input} maxLength={120} />
|
||||
</Field>
|
||||
<Field label="Província histórica">
|
||||
<input name="historical_province" className={input} maxLength={120} />
|
||||
</Field>
|
||||
<Field label="Fonte da localização histórica">
|
||||
<input name="historical_source_reference" className={input} maxLength={2000} />
|
||||
</Field>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
<button className={button} disabled={busy}>
|
||||
Guardar rascunho
|
||||
|
||||
Reference in New Issue
Block a user