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'; import type { Structure, StructureRecord, Chain } from './types'; import ValueNetwork from './value-network'; import type { ChainLink, Gap } from './value-network'; function ChainForm({ clusterId, chain }: { clusterId: string; chain?: Chain }) { const form = useForm({ code: chain?.code ?? '', name: chain?.name ?? '', stage: chain?.stage ?? 'input', }); return (
{ e.preventDefault(); const url = `/management/clusters/${clusterId}/chains`; if (chain) form.put(`${url}/${chain.id}`, { preserveScroll: true }); else form.post(url, { preserveScroll: true, onSuccess: () => form.reset(), }); }} >

{chain ? chain.name : 'Nova etapa'}

form.setData('code', e.target.value)} /> form.setData('name', e.target.value)} />
); } export default function Editor({ structure, record, projects, viewerId, chains, memberships, chainLinks, gaps, }: { structure: Structure; record: StructureRecord | null; projects: { id: string; name: string; code: string }[]; viewerId: number; chains: Chain[]; chainLinks: ChainLink[]; gaps: Gap[]; memberships: { id: string; 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' : isCluster ? 'planned' : 'proposed'), sector: record?.sector ?? '', description: record?.description ?? '', budget_amount: record?.budget_amount ?? '', budget_currency: record?.budget_currency ?? '', start_date: record?.start_date?.slice(0, 10) ?? '', end_date: record?.end_date?.slice(0, 10) ?? '', province_id: '', district_id: '', admin_post_id: '', locality_id: '', }); const association = useForm({ project_id: '', version_no: 0, role: 'complementary', association_type: 'potential', source_reference: '', evidence_reference: '', valid_from: '', valid_until: '', }); return ( Voltar a {titles[structure].toLowerCase()}

Registo interno de gestão. O estado activo não publica este conteúdo no portal.

{!record && ( form.setData((data) => ({ ...data, province_id: path[0]?.id ?? '', district_id: path[1]?.id ?? '', admin_post_id: path[2]?.id ?? '', locality_id: path[3]?.id ?? '', })) } /> )}
{ e.preventDefault(); if (record) form.put(`/management/${structure}/${record.id}`); else form.post(`/management/${structure}`); }} > form.setData('code', e.target.value)} /> form.setData('name', e.target.value)} /> {isCluster && ( form.setData('sector', e.target.value) } /> )} {isProject && ( <>