@@ -1,4 +1,5 @@
|
||||
import { Link, useForm, router } from "@inertiajs/react";
|
||||
import { Link, useForm, router, usePage } from "@inertiajs/react";
|
||||
import { useState } from "react";
|
||||
import InvestmentMapPanel from "@/components/investment-map-panel";
|
||||
import { Management } from "../management/shared";
|
||||
import { Layout, Field, control, button, labels, kind } from "./shared";
|
||||
@@ -8,6 +9,8 @@ export default function Show(props: Props) {
|
||||
}
|
||||
|
||||
type Props = {
|
||||
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;
|
||||
@@ -31,7 +34,11 @@ function Editor({
|
||||
opportunities = [],
|
||||
chains = [],
|
||||
zones = [],
|
||||
anchorProject = null,
|
||||
existingSubmissions = [],
|
||||
}: Props) {
|
||||
const { auth } = usePage<{ auth: { user: unknown } }>().props;
|
||||
const [creatingManifestation, setCreatingManifestation] = useState(false);
|
||||
const form = useForm({
|
||||
title: record.title,
|
||||
source: record.source,
|
||||
@@ -48,6 +55,22 @@ function Editor({
|
||||
{kind(record)} · {record.content.code}
|
||||
</p>
|
||||
<p className="text-sm">Fonte: {record.source}</p>
|
||||
{anchorProject && (
|
||||
<section className="space-y-2 rounded-xl border p-5" aria-labelledby="anchor-project-heading">
|
||||
<h2 id="anchor-project-heading" className="text-xl font-bold">Referência de projecto âncora</h2>
|
||||
<p>{anchorProject.code} · {anchorProject.name}</p>
|
||||
<p>Estado registado: {{ draft: "rascunho", planned: "previsto", active: "em execução", suspended: "suspenso", completed: "concluído", cancelled: "cancelado" }[anchorProject.status] ?? "por confirmar"}.</p>
|
||||
{anchorProject.budget_amount && <p>Investimento estimado documentado: {anchorProject.budget_amount} {anchorProject.budget_currency}</p>}
|
||||
{(anchorProject.start_date || anchorProject.end_date) && <p>Calendário registado: {anchorProject.start_date ?? "início não indicado"} – {anchorProject.end_date ?? "fim não indicado"}</p>}
|
||||
<p>Esta é uma referência de planeamento. Não significa concurso aberto, disponibilidade imediata ou convite à apresentação de propostas.</p>
|
||||
</section>
|
||||
)}
|
||||
{record.project_id && !anchorProject && (
|
||||
<section className="space-y-2 rounded-xl border p-5" aria-labelledby="anchor-status-pending-heading">
|
||||
<h2 id="anchor-status-pending-heading" className="text-xl font-bold">Referência de projecto âncora</h2>
|
||||
<p>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.</p>
|
||||
</section>
|
||||
)}
|
||||
{!management && (record.cluster_id || record.corridor_id || record.project_id) && (
|
||||
<InvestmentMapPanel
|
||||
filters={
|
||||
@@ -73,16 +96,32 @@ function Editor({
|
||||
</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>
|
||||
{!management && auth.user && (
|
||||
<div className="space-y-2 rounded-xl border p-4">
|
||||
<p>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.</p>
|
||||
{existingSubmissions.length > 0 && (
|
||||
<section className="space-y-2" aria-label="Manifestações em rascunho para esta ficha">
|
||||
<h2 className="font-semibold">Continuar um rascunho existente</h2>
|
||||
{existingSubmissions.map((submission) => <Link key={submission.id} className="block underline" href={`/investidor/manifestacoes/${submission.id}`}>Continuar rascunho actualizado em {new Date(submission.updated_at).toLocaleDateString("pt-MZ")}</Link>)}
|
||||
<p>Ou crie outra manifestação privada. Os rascunhos não serão fundidos.</p>
|
||||
</section>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={creatingManifestation}
|
||||
onClick={() => {
|
||||
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"}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{!management && !auth.user && (
|
||||
<p className="rounded-xl border p-4">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. <Link className="underline" href="/login">Entrar</Link></p>
|
||||
)}
|
||||
{chains.length > 0 && (
|
||||
<section>
|
||||
|
||||
Reference in New Issue
Block a user