varias alteracoes
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-06 14:50:12 +02:00
parent 4f35313d06
commit e65cb26901
333 changed files with 54656 additions and 2058 deletions
+48 -7
View File
@@ -1,4 +1,4 @@
import { Link, useForm } from "@inertiajs/react";
import { Link, router, useForm } from "@inertiajs/react";
import InvestmentTerritory, { TerritoryFields } from "@/components/investment-territory";
import { Management, Field, button, control } from "../management/shared";
import { titles, statuses, stages, roles } from "./types";
@@ -65,6 +65,7 @@ export default function Editor({
structure,
record,
projects,
viewerId,
chains,
memberships,
chainLinks,
@@ -73,6 +74,7 @@ export default function Editor({
structure: Structure;
record: StructureRecord | null;
projects: { id: string; name: string; code: string }[];
viewerId: number;
chains: Chain[];
chainLinks: ChainLink[];
gaps: Gap[];
@@ -81,13 +83,24 @@ export default function Editor({
project_id: string;
name: string;
role: string;
association_type: string;
source_reference: string | null;
evidence_reference: string | null;
valid_from: string | null;
valid_until: string | null;
validation_status: string;
version_no: number;
editor_id: number | null;
}[];
}) {
const isProject = structure === "projects";
const isCluster = structure === "clusters";
const isCorridor = structure === "corridors";
const singular = isProject ? "projecto" : isCluster ? "cluster" : "corredor";
const form = useForm({
code: record?.code ?? "",
name: record?.name ?? "",
status: record?.status ?? (isProject ? "draft" : "planned"),
status: record?.status ?? (isProject ? "draft" : isCluster ? "planned" : "proposed"),
sector: record?.sector ?? "",
description: record?.description ?? "",
budget_amount: record?.budget_amount ?? "",
@@ -99,9 +112,9 @@ export default function Editor({
admin_post_id: "",
locality_id: "",
});
const association = useForm({ project_id: "", role: "complementary" });
const association = useForm({ project_id: "", version_no: 0, role: "complementary", association_type: "potential", source_reference: "", evidence_reference: "", valid_from: "", valid_until: "" });
return (
<Management title={`${record ? "Editar" : "Criar"} ${isProject ? "projecto" : "cluster"}`}>
<Management title={`${record ? "Editar" : "Criar"} ${singular}`}>
<Link className="underline" href={`/management/${structure}`}>
Voltar a {titles[structure].toLowerCase()}
</Link>
@@ -155,7 +168,7 @@ export default function Editor({
))}
</select>
</Field>
{!isProject && (
{isCluster && (
<Field label="Sector do cluster" error={form.errors.sector}>
<input
className={control}
@@ -216,11 +229,21 @@ export default function Editor({
</Field>
</>
)}
{isCorridor && (
<Field label="Descrição" error={form.errors.description}>
<textarea
className={control}
rows={5}
value={form.data.description}
onChange={(e) => form.setData("description", e.target.value)}
/>
</Field>
)}
<button className={button} disabled={form.processing}>
Guardar
</button>
</form>
{!isProject && record && (
{isCluster && record && (
<>
<section className="max-w-3xl space-y-4">
<h2 className="text-xl font-semibold">Projectos associados</h2>
@@ -235,6 +258,14 @@ export default function Editor({
· {roles[member.role]}
</p>
))}
{memberships.map((member) => (
<div key={`${member.id}-governance`} className="text-sm">
{member.validation_status} - {member.association_type} - {member.source_reference ?? "Sem fonte"} - {member.evidence_reference ?? "Sem evidencia"} - {member.valid_from ?? "Sem inicio"} - {member.valid_until ?? "Sem termo"}
{member.validation_status === "pending" && member.editor_id !== viewerId && (
<button className={button} type="button" onClick={() => router.post(`/management/structure-relations/cluster-project/${member.id}/validate`, { version_no: member.version_no }, { preserveScroll: true })}>Validar associacao</button>
)}
</div>
))}
{!memberships.length && <p>Ainda não existem projectos associados.</p>}
<form
className="space-y-3"
@@ -250,7 +281,8 @@ export default function Editor({
className={control}
value={association.data.project_id}
onChange={(e) =>
association.setData("project_id", e.target.value)
association.setData((data) => ({ ...data, project_id: e.target.value,
version_no: memberships.find((member) => member.project_id === e.target.value)?.version_no ?? 0 }))
}
>
<option value="">Seleccione</option>
@@ -274,6 +306,15 @@ export default function Editor({
))}
</select>
</Field>
<Field label="Tipo de associacao" error={association.errors.association_type}>
<select className={control} value={association.data.association_type} onChange={(e) => association.setData("association_type", e.target.value)}>
<option value="official">Oficial</option><option value="influence">Influencia</option><option value="proximity">Proximidade</option><option value="potential">Potencial</option><option value="historical">Historica</option>
</select>
</Field>
<Field label="Referencia da fonte" error={association.errors.source_reference}><textarea className={control} value={association.data.source_reference} onChange={(e) => association.setData("source_reference", e.target.value)} /></Field>
<Field label="Referencia da evidencia" error={association.errors.evidence_reference}><input className={control} value={association.data.evidence_reference} onChange={(e) => association.setData("evidence_reference", e.target.value)} /></Field>
<Field label="Vigente desde" error={association.errors.valid_from}><input className={control} type="date" value={association.data.valid_from} onChange={(e) => association.setData("valid_from", e.target.value)} /></Field>
<Field label="Vigente ate" error={association.errors.valid_until}><input className={control} type="date" value={association.data.valid_until} onChange={(e) => association.setData("valid_until", e.target.value)} /></Field>
<button className={button} disabled={association.processing}>
Guardar associação
</button>
+5 -1
View File
@@ -23,7 +23,11 @@ export default function Index({
return (
<Management title={titles[structure]}>
<Link className={button} href={`/management/${structure}/create`}>
{structure === 'projects' ? 'Criar projecto' : 'Criar cluster'}
{structure === 'projects'
? 'Criar projecto'
: structure === 'clusters'
? 'Criar cluster'
: 'Criar corredor'}
</Link>
<form
className="flex flex-wrap items-end gap-3"
+3 -2
View File
@@ -1,4 +1,4 @@
export type Structure = 'projects' | 'clusters';
export type Structure = 'projects' | 'clusters' | 'corridors';
export type StructureRecord = {
id: string;
code: string;
@@ -11,7 +11,7 @@ export type StructureRecord = {
start_date?: string | null;
end_date?: string | null;
};
export const titles = { projects: 'Projectos', clusters: 'Clusters' };
export const titles = { projects: 'Projectos', clusters: 'Clusters', corridors: 'Corredores' };
export const statuses: Record<Structure, Record<string, string>> = {
projects: {
draft: 'Rascunho',
@@ -22,6 +22,7 @@ export const statuses: Record<Structure, Record<string, string>> = {
cancelled: 'Cancelado',
},
clusters: { planned: 'Planeado', active: 'Activo', inactive: 'Inactivo' },
corridors: { proposed: 'Proposto', active: 'Activo', closed: 'Encerrado' },
};
export const stages: Record<string, string> = {
input: 'Insumos',