Files
Investidor-V2/resources/js/pages/investment/detail.tsx
T
nala 6ddafc95ba
tests / ci (push) Canceled after 0s
oportunidades 4
2026-10-10 07:03:59 +02:00

297 lines
13 KiB
TypeScript

import { Link, router, usePage } from "@inertiajs/react";
import { useState } from "react";
import InvestmentMapPanel from "@/components/investment-map-panel";
import StructureGeographyPanel, {
LocationList,
} from "@/components/structure-geography";
import PartnershipSourceLinks from "@/components/partnership-source-links";
import TerritorialSources from "@/components/territorial-source-evidence";
import { Frame, card, button, money, groupLabels } from "./shared";
import type { Opportunity, Context } from "./shared";
export default function Detail({
record: r,
context: c,
zone_origin,
returnUrl = "/oportunidades",
dossierOrigin,
}: {
record: Opportunity;
context: Context;
zone_origin?: { id: string; name: string } | null;
returnUrl?: string;
dossierOrigin?: { id: string; title: string } | null;
}) {
const { auth } = usePage<{ auth: { user: unknown } }>().props;
const [sharing, setSharing] = useState("");
return (
<Frame title={r.title}>
<PartnershipSourceLinks type="investment" id={r.id} />
<Link href={returnUrl} className="underline">
Voltar à pesquisa
</Link>
{dossierOrigin && (
<p>
<Link
className="underline"
href={`/carteira/${dossierOrigin.id}`}
>
Voltar ao dossier: {dossierOrigin.title}
</Link>
</p>
)}
<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>
<TerritorialSources sources={c.source_evidence} />
<section className={card + " space-y-3"}>
<h2 className="text-xl font-bold">
Implantação declarada da oportunidade
</h2>
<p>
As relações cadastradas não confirmam disponibilidade ou
capacidade. Locais dos projetos associados, áreas de impacto
e abrangência dos clusters são apresentados separadamente.
</p>
<LocationList locations={c.opportunity_locations ?? []} />
{!c.opportunity_locations?.length && (
<p>
Implantação estruturada não documentada. O contexto
associado abaixo não confirma onde a oportunidade será
implantada.
</p>
)}
</section>
<InvestmentMapPanel
filters={{ opportunity_id: r.id }}
territoryId={c.primary_territory_path?.at(-1)?.id}
/>
{c.primary_territory_path &&
c.primary_territory_path.length > 0 && (
<p>
Território principal cadastrado (implantação por
confirmar):{" "}
{c.primary_territory_path
.map((node) => node.name)
.join(" → ")}
</p>
)}
<div className="flex flex-wrap gap-4">
{auth.user ? (
<button
className={button}
onClick={() =>
router.post("/investidor/manifestacoes", {
opportunity_id: r.id,
...(zone_origin
? {
zone_id: zone_origin.id,
intent: "interest",
}
: {}),
})
}
>
Preparar manifestação de interesse
</button>
) : (
<Link className={button} href="/login">
Entrar para preparar manifestação
</Link>
)}
<Link
className="underline"
href={`/manifestar-interesse/${r.slug}`}
>
Contacto rápido sem rascunho
</Link>
<button
className="underline"
onClick={() => {
if (!navigator.clipboard) {
setSharing(
"Copie a ligação na barra de endereço do navegador.",
);
return;
}
navigator.clipboard
.writeText(window.location.href)
.then(() => setSharing("Ligação copiada."))
.catch(() =>
setSharing(
"Copie a ligação na barra de endereço do navegador.",
),
);
}}
>
Copiar ligação
</button>
</div>
{sharing && <p role="status">{sharing}</p>}
{!!c.zones?.length && (
<section className={card}>
<h2 className="text-xl font-bold">
ZEE, ZFI e parques associados
</h2>
{c.zones.map((z) => (
<p key={z.id}>
<Link
className="underline"
href={`/zonas?category=${z.category}&q=${encodeURIComponent(z.name)}`}
>
{z.name}
</Link>{" "}
·{" "}
{z.association_type === "official"
? "Associação documental validada"
: "Relação " + z.association_type}{" "}
· Fonte: {z.source_reference}
</p>
))}
<p>
A associação não atribui automaticamente benefícios ou
licenças.
</p>
</section>
)}
<div className="grid gap-6 lg:grid-cols-3">
<section
className={card + " whitespace-pre-line lg:col-span-2"}
>
<h2 className="mb-3 text-xl font-bold">O investimento</h2>
{r.description || "Descrição por completar."}
</section>
<dl className={card + " space-y-4"}>
{[
["Promotor", r.promoter_name],
["Investimento", money(r)],
["Maturidade", r.maturity_label],
["Parceria", r.financing_modality],
["Impacto", r.expected_impact],
["Calendário", c.profile?.target_date],
].map(([key, value]) => (
<div key={key}>
<dt className="font-bold">{key}</dt>
<dd>{value || "Não indicado"}</dd>
</div>
))}
</dl>
</div>
{c.profile && (
<section className={card + " space-y-4"}>
<h2 className="text-xl font-bold">
Viabilidade e preparação
</h2>
{[
["Modelo de negócio", c.profile.business_model],
["Requisitos", c.profile.requirements],
["Riscos", c.profile.risks],
["Fonte", c.profile.source_reference],
].map(([label, text]) => (
<div key={label}>
<h3 className="font-bold">{label}</h3>
<p className="whitespace-pre-line">
{text || "Não indicado"}
</p>
</div>
))}
{c.profile.is_education && (
<Link href="/educacao" className="underline">
Explorar oportunidades na educação
</Link>
)}
</section>
)}
<section className="grid gap-4 md:grid-cols-4">
{(
["clusters", "corridors", "projects", "locations"] as const
).map((key, i) => (
<div className={card} key={key}>
<h2 className="font-bold">
{
[
"Clusters",
"Corredores",
"Projectos âncora",
"Territórios",
][i]
}
</h2>
{c[key].map((entity) => (
<p key={entity.id}>
{entity.dossiers?.map((dossier) => (
<span key={dossier.id}>
<Link
className="underline"
href={`/carteira/${dossier.id}`}
>
Consultar dossier: {dossier.title}
</Link>
<br />
</span>
))}
<Link
className="underline"
href={
"/oportunidades?" +
[
"cluster_id",
"corridor_id",
"project_id",
"geo_location_id",
][i] +
"=" +
entity.id
}
>
{entity.name}
</Link>
</p>
))}
{!c[key].length && <p>Sem relação publicada.</p>}
</div>
))}
</section>
{(["projects", "clusters"] as const).flatMap((key) =>
c[key]
.filter(
(entity) => entity.geography && entity.dossiers?.length,
)
.map((entity) => (
<StructureGeographyPanel
key={`${key}-${entity.id}`}
geography={entity.geography!}
cluster={key === "clusters"}
dossierId={entity.dossiers![0].id}
/>
)),
)}
<section className={card}>
<h2 className="text-xl font-bold">
Infraestruturas, competências, educação e apoios
</h2>
{c.facets.map((f) => (
<p key={f.id}>
{groupLabels[f.group] ?? f.group}: {f.label}
</p>
))}
{!c.facets.length && (
<p>
Sem características estruturadas publicadas. Pode
declarar as suas necessidades na manifestação de
interesse.
</p>
)}
</section>
</Frame>
);
}