Prepare supplied financial directory with product coverage and native dossier continuity

This commit is contained in:
2026-11-10 18:51:23 +02:00
parent c8e0a7ee39
commit 5ff9402fd0
25 changed files with 2730 additions and 37 deletions
+48 -2
View File
@@ -1,3 +1,8 @@
import {
InstitutionFields,
emptyInstitution,
type InstitutionDetails,
} from '@/components/funding-institution';
import { Link, router, useForm } from '@inertiajs/react';
import { useState } from 'react';
import type { ReactNode } from 'react';
@@ -21,7 +26,8 @@ type WindowDraft = {
application_url: string;
criteria: Criterion[];
};
type Draft = {
type Draft = InstitutionDetails & {
funding_needs: string[];
title: string;
kind: string;
summary: string;
@@ -51,6 +57,8 @@ type RecordData = {
};
type Plan = { version: number; hash: string; payload: Draft };
const empty: Draft = {
...emptyInstitution,
funding_needs: [],
title: '',
kind: 'fund',
summary: '',
@@ -239,6 +247,8 @@ function Editor({
kinds,
windowModes,
history,
institutionNatures = {},
needs = {},
}: {
record: RecordData | null;
references: Record<
@@ -247,6 +257,8 @@ function Editor({
>;
kinds: Record<string, string>;
windowModes: Record<string, string>;
institutionNatures?: Record<string, string>;
needs?: Record<string, string>;
history: { version: number; reason: string; published_at: string }[];
}) {
const form = useForm({
@@ -359,6 +371,31 @@ function Editor({
))}
</select>
</Field>
{draft.kind !== 'institution' && (
<label>
Finalidades documentadas
<select
multiple
className={input}
value={draft.funding_needs}
onChange={(e) =>
change({
funding_needs: Array.from(
e.target.selectedOptions,
(o) => o.value,
),
})
}
>
{Object.entries(needs).map(([id, label]) => (
<option key={id} value={id}>
{label}
</option>
))}
</select>
<span>Sem selecção: finalidade por confirmar.</span>
</label>
)}
<Field label="Resumo">
<textarea
className={input}
@@ -419,8 +456,17 @@ function Editor({
</select>
</Field>
</section>
{draft.kind === 'institution' && (
<InstitutionFields
value={draft}
change={change}
territories={references.territories}
natures={institutionNatures}
needs={needs}
/>
)}
<section className={card}>
<Field label="Cobertura do programa">
<Field label="Cobertura do programa/instituição — distinta da presença física">
<select
className={input}
value={draft.coverage}
+28 -2
View File
@@ -8,6 +8,7 @@ export default function Index({
kinds,
management,
options,
needs = {},
}: {
items: {
data: Programme[];
@@ -20,15 +21,22 @@ export default function Index({
territory?: string;
certainty?: string;
state?: string;
need?: string;
context?: string;
opportunity?: string;
};
options: {
sectors: { id: number; name: string }[];
territories: { id: string; name: string }[];
};
kinds: Record<string, string>;
needs?: Record<string, string>;
management: boolean;
}) {
const form = useForm({
context: filters.context ?? '',
opportunity: filters.opportunity ?? '',
need: filters.need ?? '',
q: filters.q ?? '',
kind: filters.kind ?? '',
sector: filters.sector ?? '',
@@ -37,7 +45,7 @@ export default function Index({
state: filters.state ?? '',
});
return (
<Frame title="Fundos e programas de apoio">
<Frame title="Instituições financeiras, fundos e programas de apoio">
{management && (
<Link className={button} href="/management/fundos">
Gerir fundos e programas
@@ -57,6 +65,21 @@ export default function Index({
form.get('/fundos');
}}
>
<label>
Necessidade de financiamento
<select
className="block rounded border p-2"
value={form.data.need}
onChange={(e) => form.setData('need', e.target.value)}
>
<option value="">Todas / por identificar</option>
{Object.entries(needs).map(([id, label]) => (
<option key={id} value={id}>
{label}
</option>
))}
</select>
</label>
<label>
Palavras-chave
<input
@@ -164,7 +187,10 @@ export default function Index({
{items.data.map((item) => (
<article className={card} key={item.id}>
<h2 className="text-xl font-semibold">
<Link className="underline" href={`/fundos/${item.id}`}>
<Link
className="underline"
href={`/fundos/${item.id}?${new URLSearchParams(Object.entries(filters).filter((entry): entry is [string, string] => typeof entry[1] === 'string'))}`}
>
{item.payload.title}
</Link>
</h2>
+21 -6
View File
@@ -2,7 +2,9 @@ import { Link } from '@inertiajs/react';
import { Frame, card, button } from '@/pages/investment/shared';
export default function Manage({
items,
references = [],
}: {
references?: { code: string; title: string }[];
items: {
data: {
id: string;
@@ -21,12 +23,25 @@ export default function Manage({
<Link className="ml-4 underline" href="/fundos">
Catálogo público
</Link>
<Link
className="ml-4 underline"
href="/management/fundos/referencias/fdel"
>
Preparar referência FDEL
</Link>
<details className={card}>
<summary>
Preparar referências fornecidas ({references.length})
</summary>
<p>
Prepara rascunhos privados; repetições reutilizam a ficha e
preservam edições. Publicação é conferida separadamente.
</p>
{references.map((r) => (
<p key={r.code}>
<Link
className="underline"
href={`/management/fundos/referencias/${r.code}`}
>
{r.title}
</Link>
</p>
))}
</details>
{items.data.map((item) => (
<article className={card} key={item.id}>
<Link
+10
View File
@@ -1,3 +1,7 @@
import {
InstitutionView,
type InstitutionDetails,
} from '@/components/funding-institution';
import { Link, useForm } from '@inertiajs/react';
import { Frame, card, button } from '@/pages/investment/shared';
import type { Criterion } from './shared';
@@ -7,6 +11,7 @@ type Reference = {
edition: string;
provenance: { url: string; checked_on: string; reference: string }[];
draft: {
kind?: string;
title: string;
summary: string;
manager_name: string;
@@ -61,6 +66,11 @@ export default function ReferencePage({ reference }: { reference: Reference }) {
<p>{reference.draft.sectors_text}</p>
<Criteria items={reference.draft.criteria} />
</section>
{reference.draft.kind === 'institution' && (
<InstitutionView
value={reference.draft as unknown as InstitutionDetails}
/>
)}
<section className={card}>
<h2>Chamadas documentadas</h2>
{reference.draft.windows.map((window) => (
+2 -1
View File
@@ -1,3 +1,4 @@
import type { InstitutionDetails } from '@/components/funding-institution';
export type Criterion = {
code: string;
question: string;
@@ -28,7 +29,7 @@ export type Programme = {
version_id: string;
version: number;
published_at: string;
payload: {
payload: Partial<InstitutionDetails> & {
title: string;
kind: string;
summary: string;
+33 -1
View File
@@ -1,3 +1,11 @@
import {
InstitutionView,
type InstitutionDetails,
} from '@/components/funding-institution';
import {
FundingDossierChoice,
type FundingDossier,
} from '@/components/funding-dossier-choice';
import { Link, router } from '@inertiajs/react';
import FundingCriteriaAssessment from '@/components/funding-criteria-assessment';
import { Frame, card, button } from '@/pages/investment/shared';
@@ -7,10 +15,18 @@ export default function Show({
record,
saved,
authenticated,
dossier = null,
selection = {},
needs = {},
destinations = [],
}: {
record: Programme;
saved: { version: number; saved_at: string } | null;
authenticated: boolean;
dossier?: FundingDossier | null;
selection?: Record<string, string>;
needs?: Record<string, string>;
destinations?: { id: string; opportunity: string | null; title: string }[];
}) {
const payload = record.payload;
return (
@@ -18,10 +34,26 @@ export default function Show({
<Link className="underline" href="/fundos/guardados">
Programas que guardei
</Link>
<Link className="underline" href="/fundos">
<Link
className="underline"
href={`/fundos?${new URLSearchParams(selection)}`}
>
Voltar aos fundos e programas
</Link>
<p>{payload.summary}</p>
{payload.kind === 'institution' && (
<InstitutionView value={payload as InstitutionDetails} />
)}
{authenticated && (
<FundingDossierChoice
key={`${record.id}:${record.version_id}:${dossier?.id ?? ''}:${dossier?.opportunity ?? ''}:${selection.territory ?? ''}`}
record={record}
dossier={dossier}
selection={selection}
needs={needs}
destinations={destinations}
/>
)}
<p>
Gestor: {payload.manager_name}. Versão publicada:{' '}
{record.version}.
+54
View File
@@ -39,6 +39,20 @@ type Step = {
source_paragraph: number;
};
type Path = {
funding_selections?: {
id: string;
title: string;
programme_id: string;
version: number;
need: string;
opportunity: string | null;
notice: string;
product?: {
title: string;
conditions?: string;
availability: string;
} | null;
}[];
preparation_action?: {
id: string;
title: string;
@@ -786,6 +800,8 @@ export default function InvestmentPath(path: Path) {
{
(
{
funding:
'Instituições financeiras e apoios',
preparation: 'Preparação APIEX e SWOT',
simulator: 'Plano e simulador',
desk: 'Balcão e histórico',
@@ -1057,6 +1073,44 @@ export default function InvestmentPath(path: Path) {
Anexar ou conferir no Balcão
</Link>
</section>
<section
id="financiamento"
className="rounded-xl border bg-white p-4"
>
<h2>Referências de financiamento do dossier</h2>
<p>
Escolhas privadas para preparação; não são candidaturas
enviadas nem concessões de financiamento.
</p>
{path.tools.funding && (
<Link className="underline" href={path.tools.funding}>
Pesquisar instituições e apoios para este investimento
</Link>
)}
{(path.funding_selections ?? []).map((row) => (
<article key={row.id}>
<h3>
{row.title} · versão consultada {row.version}
</h3>
<p>
{row.product?.title ?? 'Produto por confirmar'} ·{' '}
{row.need}
</p>
<p>
{row.product?.conditions ||
'Condições por confirmar'}
</p>
<p>{row.notice}</p>
<Link
className="underline"
href={`/fundos/${row.programme_id}?context=${path.case.id}${row.opportunity ? '&opportunity=' + encodeURIComponent(row.opportunity) : ''}`}
>
Consultar ficha actual (pode ter sido alterada ou
retirada)
</Link>
</article>
))}
</section>
<details id="tarefas" className="space-y-3 rounded-xl border p-4">
<summary className="cursor-pointer text-lg font-semibold">
Acompanhamento interno