import { Link, useForm, router, usePage } from '@inertiajs/react';
import { useState } from 'react';
import { catalogueReturnHref } from '@/lib/catalogue-context';
import {
searchTerritoryHref,
portfolioPreparationHref,
} from '@/lib/search-territory';
import InvestmentMapPanel from '@/components/investment-map-panel';
import StructureGeographyPanel, {
type StructureGeography,
} from '@/components/structure-geography';
import PartnershipSourceLinks from '@/components/partnership-source-links';
import { Management } from '../management/shared';
import { Layout, Field, control, button, labels, kind } from './shared';
import type { Dossier } from './shared';
import InvestmentComplements, {
type ComplementOption,
} from '@/components/investment-complements';
import ClusterCompetitivenessPublic, {
type ApprovedCompetitiveness,
} from '@/components/cluster-competitiveness-public';
export default function Show(props: Props) {
return (
);
}
type Props = {
competitiveness?: ApprovedCompetitiveness | null;
complements?: ComplementOption[];
geography: StructureGeography;
existingSubmissions?: { id: string; version: number; updated_at: string }[];
anchorProject?: {
code: string;
name: string;
status: string;
budget_amount: string | null;
budget_currency: string | null;
start_date: string | null;
end_date: string | null;
} | null;
zones?: {
id: string;
name: string;
category: string;
association_type: string;
source_reference: string;
}[];
record: Dossier;
related: Dossier[];
management: boolean;
origin: { id: string; title: string } | null;
opportunities?: {
id: number;
title: string;
slug: string;
summary: string;
}[];
chains?: { id: string; name: string; stage: string }[];
};
function Editor({
competitiveness,
complements = [],
record,
related,
management,
origin,
opportunities = [],
chains = [],
zones = [],
anchorProject = null,
existingSubmissions = [],
geography,
}: Props) {
const { auth } = usePage<{ auth: { user: unknown } }>().props;
const [creatingManifestation, setCreatingManifestation] = useState(false);
const form = useForm({
title: record.title,
source: record.source,
content: record.content,
version_no: record.version_no,
});
const approval = useForm({
approval_evidence: '',
version_no: record.version_no,
});
const save = useForm({ origin_id: origin?.id ?? null });
const Frame = management ? Management : Layout;
const base = management ? '/management/portfolio' : '/carteira';
const pageUrl = usePage().url;
return (
Voltar à pesquisa
{kind(record)} · {record.content.code}
Fonte: {record.source}
{competitiveness && (
)}
{!management && (
Preparar investimento a partir desta ficha
A ficha acompanha o dossier como origem documental. A
localização do investimento e as ofertas associadas são
escolhas próprias.
)}
{(record.project_id || record.cluster_id) && (
)}
{(record.project_id || record.cluster_id) && (
)}
{anchorProject && (
Referência de projecto âncora
{anchorProject.code} · {anchorProject.name}
Estado registado:{' '}
{{
draft: 'rascunho',
planned: 'previsto',
active: 'em execução',
suspended: 'suspenso',
completed: 'concluído',
cancelled: 'cancelado',
}[anchorProject.status] ?? 'por confirmar'}
.
{anchorProject.budget_amount && (
Investimento estimado documentado:{' '}
{anchorProject.budget_amount}{' '}
{anchorProject.budget_currency}
)}
{(anchorProject.start_date || anchorProject.end_date) && (
Calendário registado:{' '}
{anchorProject.start_date ?? 'início não indicado'}{' '}
– {anchorProject.end_date ?? 'fim não indicado'}
)}
Esta é uma referência de planeamento. Não significa
concurso aberto, disponibilidade imediata ou convite à
apresentação de propostas.
)}
{record.project_id && !anchorProject && (
Referência de projecto âncora
O estado de execução e o investimento não estão
confirmados num registo publicável. A referência do
dossier não representa concurso aberto nem
disponibilidade imediata.
)}
{!management &&
(record.cluster_id ||
record.corridor_id ||
record.project_id) && (
)}
{zones.length > 0 && (
ZEE, ZFI e parques relacionados
{zones.map((z) => (
{z.name}
{' '}
· {z.association_type} · Fonte: {z.source_reference}
))}
)}
{origin && Exploração iniciada em: {origin.title}
}
{!management && }
{!management && auth.user && (
As manifestações ficam privadas até uma submissão
separada. A referência não copia nem publica o dossier
público no seu nome.
{existingSubmissions.length > 0 && (
Continuar um rascunho existente
{existingSubmissions.map((submission) => (
Continuar rascunho actualizado em{' '}
{new Date(
submission.updated_at,
).toLocaleDateString('pt-MZ')}
))}
Ou crie outra manifestação privada. Os rascunhos
não serão fundidos.
)}
{
if (
!window.confirm(
`Criar ${existingSubmissions.length ? 'outra' : 'uma'} manifestação privada associada a “${record.title}”? Pode continuar a editá-la antes de submeter. Os rascunhos existentes não serão alterados.`,
)
)
return;
setCreatingManifestation(true);
router.post(
'/investidor/manifestacoes',
{ dossier_id: record.id },
{
onFinish: () =>
setCreatingManifestation(false),
},
);
}}
>
{creatingManifestation
? 'A preparar…'
: 'Preparar manifestação privada'}
)}
{!management && !auth.user && (
Para associar esta referência a uma manifestação privada,
entre na sua conta. Esta ficha continuará pública e não será
copiada nem publicada no seu nome.{' '}
{
const query = new URL(
pageUrl,
'https://portal.invalid',
).searchParams.get('catalogue_query');
return query
? '?catalogue_query=' +
encodeURIComponent(query)
: '';
})()
}
>
Entrar
)}
{chains.length > 0 && (
Cadeia de valor
{chains.map((chain) => (
{chain.name} —{' '}
{(
{
input: 'Insumos',
production: 'Produção',
processing: 'Transformação',
logistics: 'Logística',
market: 'Mercado',
} as Record
)[chain.stage] ?? chain.stage}
))}
)}
Oportunidades relacionadas
{opportunities.map((opportunity) => (
{opportunity.title}
{opportunity.summary}
))}
{!opportunities.length && (
Sem oportunidades publicadas associadas a esta ficha.
)}
{management ? (
<>
Versão editorial: {record.version_no}. Guarde as
alterações antes de publicar.
{
e.preventDefault();
approval.post(`${base}/${record.id}/publish`);
}}
>
O gestor autorizado pode aprovar e publicar esta
ficha. Registe a referência da sua decisão.
approval.setData(
'approval_evidence',
e.target.value,
)
}
/>
{approval.errors.approval_evidence && (
{approval.errors.approval_evidence}
)}
Validar e publicar
>
) : (
<>
{Object.entries(record.content)
.filter(([k]) => k !== 'name' && k !== 'code')
.map(([key, value]) => (
{labels[key] ?? key}
{value}
))}
{
e.preventDefault();
save.post(`/investidor/guardar/${record.id}`);
}}
>
Guardar no painel e preparar interesse
Acesso com conta e email verificado.
>
)}
Percurso de execução
Explore as relações entre corredor, cluster e projecto
âncora.
Consulte as componentes, parceiros e oportunidades de
participação da ficha.
Guarde a ficha no painel do investidor e manifeste
interesse com o papel e prazo pretendidos.
A equipa acompanha o pedido no CRM, com responsável e
próxima acção.
{management && (
{record.project_id && (
Gerir projecto
)}
{record.cluster_id && (
Gerir cadeias e lacunas do cluster
)}
Acompanhar pedidos
{record.publication_status === 'published' && (
Abrir ficha pública
)}
)}
Relações na carteira
{related.map((r) => (
{kind(r)}:{' '}
{r.title}
))}
{!related.length && (
Sem relações disponíveis para consulta.
)}
);
}