181 lines
8.0 KiB
TypeScript
181 lines
8.0 KiB
TypeScript
import { Link, router, usePage } from "@inertiajs/react";
|
|
import { useState } from "react";
|
|
import InvestmentMapPanel from "@/components/investment-map-panel";
|
|
import { Frame, card, button, money, groupLabels } from "./shared";
|
|
import type { Opportunity, Context } from "./shared";
|
|
export default function Detail({
|
|
record: r,
|
|
context: c,
|
|
zone_origin,
|
|
}: {
|
|
record: Opportunity;
|
|
context: Context;
|
|
zone_origin?: { id: string; name: string } | null;
|
|
}) {
|
|
const { auth } = usePage<{ auth: { user: unknown } }>().props;
|
|
const [sharing, setSharing] = useState("");
|
|
return (
|
|
<Frame title={r.title}>
|
|
<p>
|
|
{r.reference} · {r.sector?.name} · {r.province} {r.district}
|
|
</p>
|
|
<p className="text-xl">{r.summary}</p>
|
|
<InvestmentMapPanel filters={{ opportunity_id: r.id }} />
|
|
{c.primary_territory_path && c.primary_territory_path.length > 0 && (
|
|
<p>Localização: {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}>
|
|
<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>
|
|
<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>
|
|
);
|
|
}
|