@@ -0,0 +1,263 @@
|
||||
import { Link, useForm, router } from "@inertiajs/react";
|
||||
import { Management } from "../management/shared";
|
||||
import { Layout, Field, control, button, labels, kind } from "./shared";
|
||||
import type { Dossier } from "./shared";
|
||||
export default function Show(props: Props) {
|
||||
return <Editor key={`${props.record.id}:${props.record.version_no ?? 0}`} {...props} />;
|
||||
}
|
||||
|
||||
type Props = {
|
||||
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({
|
||||
record,
|
||||
related,
|
||||
management,
|
||||
origin,
|
||||
opportunities = [],
|
||||
chains = [],
|
||||
zones = [],
|
||||
}: Props) {
|
||||
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";
|
||||
return (
|
||||
<Frame title={record.title}>
|
||||
<p>
|
||||
{kind(record)} · {record.content.code}
|
||||
</p>
|
||||
<p className="text-sm">Fonte: {record.source}</p>
|
||||
{zones.length > 0 && (
|
||||
<section>
|
||||
<h2 className="text-xl font-bold">ZEE, ZFI e parques relacionados</h2>
|
||||
{zones.map((z) => (
|
||||
<p key={z.id}>
|
||||
<Link className="underline" href={`/zonas/${z.id}`}>
|
||||
{z.name}
|
||||
</Link>{" "}
|
||||
· {z.association_type} · Fonte: {z.source_reference}
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
{origin && <p>Exploração iniciada em: {origin.title}</p>}
|
||||
{!management && (
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
onClick={() =>
|
||||
router.post("/investidor/manifestacoes", { dossier_id: record.id })
|
||||
}
|
||||
>
|
||||
Preparar manifestação com necessidades e anexos
|
||||
</button>
|
||||
)}
|
||||
{chains.length > 0 && (
|
||||
<section>
|
||||
<h2 className="text-xl font-bold">Cadeia de valor</h2>
|
||||
{chains.map((chain) => (
|
||||
<p key={chain.id}>
|
||||
{chain.name} —{" "}
|
||||
{(
|
||||
{
|
||||
input: "Insumos",
|
||||
production: "Produção",
|
||||
processing: "Transformação",
|
||||
logistics: "Logística",
|
||||
market: "Mercado",
|
||||
} as Record<string, string>
|
||||
)[chain.stage] ?? chain.stage}
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-xl font-bold">Oportunidades relacionadas</h2>
|
||||
{opportunities.map((opportunity) => (
|
||||
<article key={opportunity.id}>
|
||||
<Link
|
||||
className="font-semibold underline"
|
||||
href={`/oportunidades/${opportunity.slug}`}
|
||||
>
|
||||
{opportunity.title}
|
||||
</Link>
|
||||
<p>{opportunity.summary}</p>
|
||||
</article>
|
||||
))}
|
||||
{!opportunities.length && (
|
||||
<p>Sem oportunidades publicadas associadas a esta ficha.</p>
|
||||
)}
|
||||
</section>
|
||||
{management ? (
|
||||
<>
|
||||
<p>
|
||||
Versão editorial: {record.version_no}. Guarde as alterações antes de
|
||||
publicar.
|
||||
</p>
|
||||
<form
|
||||
className="space-y-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.put(`${base}/${record.id}`);
|
||||
}}
|
||||
>
|
||||
<Field label="Título">
|
||||
<input
|
||||
className={control}
|
||||
value={form.data.title}
|
||||
onChange={(e) => form.setData("title", e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="Fonte e versão">
|
||||
<input
|
||||
className={control}
|
||||
value={form.data.source}
|
||||
onChange={(e) => form.setData("source", e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
{Object.entries(form.data.content).map(([key, value]) => (
|
||||
<Field key={key} label={labels[key] ?? key}>
|
||||
<textarea
|
||||
className={control}
|
||||
value={value ?? ""}
|
||||
onChange={(e) =>
|
||||
form.setData("content", {
|
||||
...form.data.content,
|
||||
[key]: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
))}
|
||||
{Object.entries(form.errors).map(([k, v]) => (
|
||||
<p role="alert" key={k}>
|
||||
{v}
|
||||
</p>
|
||||
))}
|
||||
<button disabled={form.processing} className={button}>
|
||||
Guardar rascunho
|
||||
</button>
|
||||
</form>
|
||||
<form
|
||||
className="space-y-3 rounded border p-4"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
approval.post(`${base}/${record.id}/publish`);
|
||||
}}
|
||||
>
|
||||
<p>
|
||||
O gestor autorizado pode aprovar e publicar esta ficha. Registe a
|
||||
referência da sua decisão.
|
||||
</p>
|
||||
<Field label="Referência da autorização e revisão">
|
||||
<textarea
|
||||
className={control}
|
||||
required
|
||||
minLength={15}
|
||||
value={approval.data.approval_evidence}
|
||||
onChange={(e) =>
|
||||
approval.setData("approval_evidence", e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
{approval.errors.approval_evidence && (
|
||||
<p role="alert">{approval.errors.approval_evidence}</p>
|
||||
)}
|
||||
<button className={button} disabled={approval.processing || form.isDirty}>
|
||||
Validar e publicar
|
||||
</button>
|
||||
</form>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<dl className="space-y-5">
|
||||
{Object.entries(record.content)
|
||||
.filter(([k]) => k !== "name" && k !== "code")
|
||||
.map(([key, value]) => (
|
||||
<div key={key}>
|
||||
<dt className="font-semibold">{labels[key] ?? key}</dt>
|
||||
<dd className="mt-1 whitespace-pre-line">{value}</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
save.post(`/investidor/guardar/${record.id}`);
|
||||
}}
|
||||
>
|
||||
<button className={button} disabled={save.processing}>
|
||||
Guardar no painel e preparar interesse
|
||||
</button>
|
||||
<p className="mt-2 text-sm">Acesso com conta e email verificado.</p>
|
||||
</form>
|
||||
</>
|
||||
)}
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-xl font-semibold">Percurso de execução</h2>
|
||||
<ol className="list-decimal space-y-2 pl-6">
|
||||
<li>Explore as relações entre corredor, cluster e projecto âncora.</li>
|
||||
<li>
|
||||
Consulte as componentes, parceiros e oportunidades de participação da ficha.
|
||||
</li>
|
||||
<li>
|
||||
Guarde a ficha no painel do investidor e manifeste interesse com o papel e
|
||||
prazo pretendidos.
|
||||
</li>
|
||||
<li>A equipa acompanha o pedido no CRM, com responsável e próxima acção.</li>
|
||||
</ol>
|
||||
{management && (
|
||||
<div className="flex flex-wrap gap-4 underline">
|
||||
{record.project_id && (
|
||||
<Link href={`/management/projects/${record.project_id}/edit`}>
|
||||
Gerir projecto
|
||||
</Link>
|
||||
)}
|
||||
{record.cluster_id && (
|
||||
<Link href={`/management/clusters/${record.cluster_id}/edit`}>
|
||||
Gerir cadeias e lacunas do cluster
|
||||
</Link>
|
||||
)}
|
||||
<Link href="/management/interests">Acompanhar pedidos</Link>
|
||||
{record.publication_status === "published" && (
|
||||
<Link href={`/carteira/${record.id}`}>Abrir ficha pública</Link>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<h2 className="text-xl font-semibold">Relações na carteira</h2>
|
||||
{related.map((r) => (
|
||||
<p key={r.id}>
|
||||
{kind(r)}:{" "}
|
||||
<Link
|
||||
className="underline"
|
||||
href={`${base}/${r.id}${management ? "" : `?from=${record.id}`}`}
|
||||
>
|
||||
{r.title}
|
||||
</Link>
|
||||
</p>
|
||||
))}
|
||||
{!related.length && <p>Sem relações disponíveis para consulta.</p>}
|
||||
</section>
|
||||
</Frame>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user