Prepare supplied financial directory with product coverage and native dossier continuity
This commit is contained in:
@@ -0,0 +1,207 @@
|
||||
import { Link, router } from '@inertiajs/react';
|
||||
import { useRef, useState } from 'react';
|
||||
import { profileJson, ProfileValidationError } from '@/lib/profile-json';
|
||||
import { createOperationKey } from '@/lib/operation-key';
|
||||
import { card, input, button } from '@/pages/investment/shared';
|
||||
import type { Programme } from '@/pages/funding/shared';
|
||||
|
||||
export type FundingDossier = {
|
||||
id: string;
|
||||
version: number;
|
||||
opportunity: string | null;
|
||||
closed: boolean;
|
||||
href: string;
|
||||
};
|
||||
export function FundingDossierChoice({
|
||||
record,
|
||||
dossier,
|
||||
selection,
|
||||
needs,
|
||||
destinations,
|
||||
}: {
|
||||
record: Programme;
|
||||
dossier: FundingDossier | null;
|
||||
selection: Record<string, string>;
|
||||
needs: Record<string, string>;
|
||||
destinations: { id: string; opportunity: string | null; title: string }[];
|
||||
}) {
|
||||
const [need, setNeed] = useState(selection.need ?? '');
|
||||
const [product, setProduct] = useState('');
|
||||
const [consent, setConsent] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
const [result, setResult] = useState<FundingDossier | null>(null);
|
||||
const pending = useRef<Record<string, unknown> | null>(null);
|
||||
const running = useRef(false);
|
||||
async function save() {
|
||||
if (!dossier || running.current) return;
|
||||
if (!pending.current)
|
||||
pending.current = {
|
||||
context: dossier.id,
|
||||
opportunity: dossier.opportunity,
|
||||
version: dossier.version,
|
||||
version_id: record.version_id,
|
||||
product: product || null,
|
||||
need,
|
||||
territory: selection.territory,
|
||||
consent,
|
||||
operation_key: createOperationKey(),
|
||||
};
|
||||
running.current = true;
|
||||
setBusy(true);
|
||||
setError('');
|
||||
try {
|
||||
setResult(
|
||||
(await profileJson(
|
||||
`/fundos/${record.id}/dossier`,
|
||||
pending.current,
|
||||
'POST',
|
||||
)) as FundingDossier,
|
||||
);
|
||||
pending.current = null;
|
||||
} catch (e) {
|
||||
setError(
|
||||
e instanceof Error
|
||||
? e.message
|
||||
: 'Resultado por confirmar. Repita a mesma intenção.',
|
||||
);
|
||||
if (
|
||||
e instanceof ProfileValidationError &&
|
||||
e.status !== null &&
|
||||
e.status >= 400 &&
|
||||
e.status < 500 &&
|
||||
e.status !== 408
|
||||
)
|
||||
pending.current = null;
|
||||
} finally {
|
||||
running.current = false;
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<section className={card}>
|
||||
<h2>Continuar a preparação no meu dossier</h2>
|
||||
<p>
|
||||
Conserva a referência, versão, produto, local e necessidade. Não
|
||||
envia candidatura ou dados à instituição.
|
||||
</p>
|
||||
{!dossier ? (
|
||||
<label>
|
||||
Escolher dossier e oportunidade existentes
|
||||
<select
|
||||
className={input}
|
||||
defaultValue=""
|
||||
onChange={(e) => {
|
||||
const chosen = destinations[Number(e.target.value)];
|
||||
if (chosen)
|
||||
router.get(`/fundos/${record.id}`, {
|
||||
...selection,
|
||||
context: chosen.id,
|
||||
opportunity: chosen.opportunity ?? '',
|
||||
});
|
||||
}}
|
||||
>
|
||||
<option value="">Seleccionar</option>
|
||||
{destinations.map((d, i) => (
|
||||
<option key={`${d.id}:${d.opportunity}`} value={i}>
|
||||
{d.title}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
) : result ? (
|
||||
<Link className={button} href={result.href}>
|
||||
Escolha guardada — continuar no mesmo dossier
|
||||
</Link>
|
||||
) : (
|
||||
<>
|
||||
<fieldset
|
||||
disabled={
|
||||
busy || Boolean(pending.current) || dossier.closed
|
||||
}
|
||||
>
|
||||
<label>
|
||||
Necessidade
|
||||
<select
|
||||
className={input}
|
||||
value={need}
|
||||
onChange={(e) => setNeed(e.target.value)}
|
||||
>
|
||||
<option value="">Seleccionar</option>
|
||||
{Object.entries(needs).map(([id, label]) => (
|
||||
<option key={id} value={id}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{record.payload.kind === 'institution' &&
|
||||
(record.payload.products ?? []).length > 0 && (
|
||||
<label>
|
||||
Programa/produto
|
||||
<select
|
||||
className={input}
|
||||
value={product}
|
||||
onChange={(e) =>
|
||||
setProduct(e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
Seleccionar e conferir
|
||||
cobertura/condições
|
||||
</option>
|
||||
{record.payload.products?.map((p) => (
|
||||
<option key={p.code} value={p.code}>
|
||||
{p.title} ·{' '}
|
||||
{p.availability === 'unknown'
|
||||
? 'Disponibilidade por confirmar'
|
||||
: p.availability ===
|
||||
'closed'
|
||||
? 'Encerrado'
|
||||
: 'Oferta identificada'}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
<p>
|
||||
Local seleccionado:{' '}
|
||||
{selection.territory
|
||||
? selection.territory_label ||
|
||||
'Conservado da pesquisa; consulte a cobertura do produto.'
|
||||
: 'Volte à pesquisa e escolha a localização antes de guardar.'}
|
||||
</p>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={consent}
|
||||
onChange={(e) => setConsent(e.target.checked)}
|
||||
/>
|
||||
Conservar esta referência privada no dossier;
|
||||
financiamento não garantido.
|
||||
</label>
|
||||
</fieldset>
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={
|
||||
busy ||
|
||||
dossier.closed ||
|
||||
(!pending.current &&
|
||||
(!consent || !need || !selection.territory))
|
||||
}
|
||||
onClick={() => void save()}
|
||||
>
|
||||
{pending.current
|
||||
? 'Repetir a mesma intenção'
|
||||
: 'Guardar e continuar no dossier'}
|
||||
</button>
|
||||
{dossier.closed && (
|
||||
<p>Dossier encerrado; consulta preservada.</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{error && <p role="alert">{error}</p>}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,636 @@
|
||||
import { card, input, button } from '@/pages/investment/shared';
|
||||
|
||||
export type FundingSource = {
|
||||
source_url: string;
|
||||
source_reference: string;
|
||||
checked_on: string;
|
||||
};
|
||||
export type FundingContact = FundingSource & { kind: string; value: string };
|
||||
export type FundingLocation = FundingSource & {
|
||||
role: string;
|
||||
label: string;
|
||||
address: string;
|
||||
territory_id: string;
|
||||
territory_path?: { name: string }[];
|
||||
};
|
||||
export type FundingProduct = FundingSource & {
|
||||
code: string;
|
||||
title: string;
|
||||
instrument: string;
|
||||
needs: string[];
|
||||
coverage: string;
|
||||
coverage_text: string;
|
||||
territory_ids: string[];
|
||||
territory_paths?: { name: string }[][];
|
||||
conditions: string;
|
||||
amounts: string;
|
||||
availability: string;
|
||||
contact_url: string;
|
||||
};
|
||||
export type InstitutionDetails = {
|
||||
institution_key: string;
|
||||
institution_nature: string;
|
||||
contacts: FundingContact[];
|
||||
locations: FundingLocation[];
|
||||
products: FundingProduct[];
|
||||
};
|
||||
export const emptyInstitution: InstitutionDetails = {
|
||||
institution_key: '',
|
||||
institution_nature: 'unknown',
|
||||
contacts: [],
|
||||
locations: [],
|
||||
products: [],
|
||||
};
|
||||
const source: FundingSource = {
|
||||
source_url: '',
|
||||
source_reference: '',
|
||||
checked_on: '',
|
||||
};
|
||||
function Text({
|
||||
label,
|
||||
value,
|
||||
change,
|
||||
type = 'text',
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
change: (v: string) => void;
|
||||
type?: string;
|
||||
}) {
|
||||
return (
|
||||
<label className="my-2 block">
|
||||
{label}
|
||||
<input
|
||||
className={input}
|
||||
type={type}
|
||||
value={value ?? ''}
|
||||
maxLength={type === 'text' ? 1500 : undefined}
|
||||
onChange={(e) => change(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
function Sources({
|
||||
value,
|
||||
change,
|
||||
}: {
|
||||
value: FundingSource;
|
||||
change: (v: Partial<FundingSource>) => void;
|
||||
}) {
|
||||
return (
|
||||
<details>
|
||||
<summary>Fonte e data deste elemento — Alterar</summary>
|
||||
<Text
|
||||
label="Endereço da fonte"
|
||||
type="url"
|
||||
value={value.source_url}
|
||||
change={(source_url) => change({ source_url })}
|
||||
/>
|
||||
<Text
|
||||
label="Referência/edição"
|
||||
value={value.source_reference}
|
||||
change={(source_reference) => change({ source_reference })}
|
||||
/>
|
||||
<Text
|
||||
label="Data de consulta"
|
||||
type="date"
|
||||
value={value.checked_on}
|
||||
change={(checked_on) => change({ checked_on })}
|
||||
/>
|
||||
</details>
|
||||
);
|
||||
}
|
||||
export function InstitutionFields({
|
||||
value,
|
||||
change,
|
||||
territories,
|
||||
natures,
|
||||
needs,
|
||||
}: {
|
||||
value: InstitutionDetails;
|
||||
change: (patch: Partial<InstitutionDetails>) => void;
|
||||
territories: { id: string | number; name?: string }[];
|
||||
natures: Record<string, string>;
|
||||
needs: Record<string, string>;
|
||||
}) {
|
||||
const update = <K extends 'contacts' | 'locations' | 'products'>(
|
||||
key: K,
|
||||
index: number,
|
||||
patch: Partial<InstitutionDetails[K][number]>,
|
||||
) =>
|
||||
change({
|
||||
[key]: value[key].map((row, i) =>
|
||||
i === index ? { ...row, ...patch } : row,
|
||||
),
|
||||
});
|
||||
return (
|
||||
<section className={card}>
|
||||
<h2>Instituição, presença física e produtos</h2>
|
||||
<p>
|
||||
A sede ou balcão não determina a cobertura do financiamento. Não
|
||||
preencha condições desconhecidas por inferência.
|
||||
</p>
|
||||
<Text
|
||||
label="Identidade estável da instituição (referência do cadastro/fonte)"
|
||||
value={value.institution_key}
|
||||
change={(institution_key) => change({ institution_key })}
|
||||
/>
|
||||
<label>
|
||||
Natureza
|
||||
<select
|
||||
className={input}
|
||||
value={value.institution_nature}
|
||||
onChange={(e) =>
|
||||
change({ institution_nature: e.target.value })
|
||||
}
|
||||
>
|
||||
{Object.entries(natures).map(([id, label]) => (
|
||||
<option key={id} value={id}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<details>
|
||||
<summary>Contactos ({value.contacts.length}) — Alterar</summary>
|
||||
{value.contacts.map((row, i) => (
|
||||
<fieldset className={card} key={i}>
|
||||
<legend>Contacto {i + 1}</legend>
|
||||
<select
|
||||
className={input}
|
||||
value={row.kind}
|
||||
onChange={(e) =>
|
||||
update('contacts', i, { kind: e.target.value })
|
||||
}
|
||||
>
|
||||
{Object.entries({
|
||||
website: 'Página institucional',
|
||||
email: 'Email',
|
||||
phone: 'Telefone',
|
||||
address: 'Endereço postal',
|
||||
}).map(([id, label]) => (
|
||||
<option key={id} value={id}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<Text
|
||||
label="Contacto documentado"
|
||||
value={row.value}
|
||||
change={(v) => update('contacts', i, { value: v })}
|
||||
/>
|
||||
<Sources
|
||||
value={row}
|
||||
change={(v) => update('contacts', i, v)}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
change({
|
||||
contacts: value.contacts.filter(
|
||||
(_, n) => n !== i,
|
||||
),
|
||||
})
|
||||
}
|
||||
>
|
||||
Remover contacto
|
||||
</button>
|
||||
</fieldset>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={value.contacts.length >= 20}
|
||||
onClick={() =>
|
||||
change({
|
||||
contacts: [
|
||||
...value.contacts,
|
||||
{ ...source, kind: 'website', value: '' },
|
||||
],
|
||||
})
|
||||
}
|
||||
>
|
||||
Acrescentar contacto
|
||||
</button>
|
||||
</details>
|
||||
<details>
|
||||
<summary>
|
||||
Sede e balcões ({value.locations.length}) — Alterar
|
||||
</summary>
|
||||
{value.locations.map((row, i) => (
|
||||
<fieldset className={card} key={i}>
|
||||
<legend>Local físico {i + 1}</legend>
|
||||
<select
|
||||
className={input}
|
||||
value={row.role}
|
||||
onChange={(e) =>
|
||||
update('locations', i, { role: e.target.value })
|
||||
}
|
||||
>
|
||||
<option value="headquarters">Sede</option>
|
||||
<option value="branch">Balcão</option>
|
||||
<option value="contact_point">
|
||||
Contacto institucional — tipo por confirmar
|
||||
</option>
|
||||
</select>
|
||||
<Text
|
||||
label="Designação"
|
||||
value={row.label}
|
||||
change={(label) =>
|
||||
update('locations', i, { label })
|
||||
}
|
||||
/>
|
||||
<Text
|
||||
label="Morada documentada"
|
||||
value={row.address}
|
||||
change={(address) =>
|
||||
update('locations', i, { address })
|
||||
}
|
||||
/>
|
||||
<label>
|
||||
Local do cadastro
|
||||
<select
|
||||
className={input}
|
||||
value={row.territory_id ?? ''}
|
||||
onChange={(e) =>
|
||||
update('locations', i, {
|
||||
territory_id: e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
Correspondência por confirmar
|
||||
</option>
|
||||
{territories.map((t) => (
|
||||
<option key={t.id} value={t.id}>
|
||||
{t.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<Sources
|
||||
value={row}
|
||||
change={(v) => update('locations', i, v)}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
change({
|
||||
locations: value.locations.filter(
|
||||
(_, n) => n !== i,
|
||||
),
|
||||
})
|
||||
}
|
||||
>
|
||||
Remover local
|
||||
</button>
|
||||
</fieldset>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={value.locations.length >= 50}
|
||||
onClick={() =>
|
||||
change({
|
||||
locations: [
|
||||
...value.locations,
|
||||
{
|
||||
...source,
|
||||
role: 'headquarters',
|
||||
label: '',
|
||||
address: '',
|
||||
territory_id: '',
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
>
|
||||
Acrescentar sede/balcão
|
||||
</button>
|
||||
</details>
|
||||
<details>
|
||||
<summary>
|
||||
Programas/produtos ({value.products.length}) — Alterar
|
||||
</summary>
|
||||
{value.products.map((row, i) => (
|
||||
<fieldset className={card} key={row.code}>
|
||||
<legend>Produto {i + 1}</legend>
|
||||
<Text
|
||||
label="Nome documentado"
|
||||
value={row.title}
|
||||
change={(title) => update('products', i, { title })}
|
||||
/>
|
||||
<Text
|
||||
label="Instrumento"
|
||||
value={row.instrument}
|
||||
change={(instrument) =>
|
||||
update('products', i, { instrument })
|
||||
}
|
||||
/>
|
||||
<label>
|
||||
Necessidades documentadas
|
||||
<select
|
||||
multiple
|
||||
className={input}
|
||||
value={row.needs}
|
||||
onChange={(e) =>
|
||||
update('products', i, {
|
||||
needs: Array.from(
|
||||
e.target.selectedOptions,
|
||||
(o) => o.value,
|
||||
),
|
||||
})
|
||||
}
|
||||
>
|
||||
{Object.entries(needs).map(([id, label]) => (
|
||||
<option key={id} value={id}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Cobertura deste produto
|
||||
<select
|
||||
className={input}
|
||||
value={row.coverage}
|
||||
onChange={(e) =>
|
||||
update('products', i, {
|
||||
coverage: e.target.value,
|
||||
territory_ids: [],
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="unknown">Por confirmar</option>
|
||||
<option value="national">
|
||||
Nacional, segundo a fonte
|
||||
</option>
|
||||
<option value="territorial">
|
||||
Locais documentados
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
{row.coverage === 'territorial' && (
|
||||
<label>
|
||||
Locais abrangidos
|
||||
<select
|
||||
multiple
|
||||
className={input}
|
||||
value={row.territory_ids}
|
||||
onChange={(e) =>
|
||||
update('products', i, {
|
||||
territory_ids: Array.from(
|
||||
e.target.selectedOptions,
|
||||
(o) => o.value,
|
||||
),
|
||||
})
|
||||
}
|
||||
>
|
||||
{territories.map((t) => (
|
||||
<option key={t.id} value={t.id}>
|
||||
{t.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
<Text
|
||||
label="Explicação da cobertura"
|
||||
value={row.coverage_text}
|
||||
change={(coverage_text) =>
|
||||
update('products', i, { coverage_text })
|
||||
}
|
||||
/>
|
||||
<label>
|
||||
Condições — vazio significa por confirmar
|
||||
<textarea
|
||||
className={input}
|
||||
value={row.conditions}
|
||||
maxLength={4000}
|
||||
onChange={(e) =>
|
||||
update('products', i, {
|
||||
conditions: e.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<Text
|
||||
label="Montantes/moeda/prazos documentados — se conhecidos"
|
||||
value={row.amounts}
|
||||
change={(amounts) =>
|
||||
update('products', i, { amounts })
|
||||
}
|
||||
/>
|
||||
<label>
|
||||
Disponibilidade
|
||||
<select
|
||||
className={input}
|
||||
value={row.availability}
|
||||
onChange={(e) =>
|
||||
update('products', i, {
|
||||
availability: e.target.value,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="unknown">Por confirmar</option>
|
||||
<option value="documented">
|
||||
Oferta identificada na fonte (não é
|
||||
concessão)
|
||||
</option>
|
||||
<option value="closed">
|
||||
Encerrada segundo a fonte
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<Text
|
||||
label="Canal de contacto do produto"
|
||||
type="url"
|
||||
value={row.contact_url}
|
||||
change={(contact_url) =>
|
||||
update('products', i, { contact_url })
|
||||
}
|
||||
/>
|
||||
<Sources
|
||||
value={row}
|
||||
change={(v) => update('products', i, v)}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
change({
|
||||
products: value.products.filter(
|
||||
(_, n) => n !== i,
|
||||
),
|
||||
})
|
||||
}
|
||||
>
|
||||
Remover produto
|
||||
</button>
|
||||
</fieldset>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={value.products.length >= 40}
|
||||
onClick={() =>
|
||||
change({
|
||||
products: [
|
||||
...value.products,
|
||||
{
|
||||
...source,
|
||||
code: crypto.randomUUID(),
|
||||
title: '',
|
||||
instrument: '',
|
||||
needs: [],
|
||||
coverage: 'unknown',
|
||||
coverage_text: '',
|
||||
territory_ids: [],
|
||||
conditions: '',
|
||||
amounts: '',
|
||||
availability: 'unknown',
|
||||
contact_url: '',
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
>
|
||||
Acrescentar programa/produto
|
||||
</button>
|
||||
</details>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
function Source({ value }: { value: FundingSource }) {
|
||||
return (
|
||||
<p>
|
||||
<a
|
||||
className="underline"
|
||||
href={value.source_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{value.source_reference}
|
||||
</a>{' '}
|
||||
· consulta {value.checked_on}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
export function InstitutionView({ value }: { value: InstitutionDetails }) {
|
||||
return (
|
||||
<section className={card}>
|
||||
<h2>Instituição financeira</h2>
|
||||
<p>
|
||||
Natureza:{' '}
|
||||
{
|
||||
(
|
||||
{
|
||||
bank: 'Banco',
|
||||
credit: 'Instituição de crédito',
|
||||
microfinance: 'Microfinanças',
|
||||
investment_fund: 'Fundo de investimento',
|
||||
development:
|
||||
'Agência de desenvolvimento/financiamento',
|
||||
other: 'Outra natureza documentada',
|
||||
unknown: 'Por confirmar',
|
||||
} as Record<string, string>
|
||||
)[value.institution_nature]
|
||||
}
|
||||
</p>
|
||||
<h3>Contactos</h3>
|
||||
{value.contacts.length === 0 && <p>Contactos por confirmar.</p>}
|
||||
{value.contacts.map((c, i) => (
|
||||
<article key={i}>
|
||||
<p>
|
||||
{c.kind === 'website' ? (
|
||||
<a
|
||||
className="underline"
|
||||
href={c.value}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{c.value}
|
||||
</a>
|
||||
) : (
|
||||
c.value
|
||||
)}
|
||||
</p>
|
||||
<Source value={c} />
|
||||
</article>
|
||||
))}
|
||||
<h3>Sede e balcões — presença física</h3>
|
||||
{value.locations.length === 0 && (
|
||||
<p>Localização física por confirmar.</p>
|
||||
)}
|
||||
{value.locations.map((l, i) => (
|
||||
<article key={i}>
|
||||
<p>
|
||||
{l.role === 'headquarters'
|
||||
? 'Sede'
|
||||
: l.role === 'branch'
|
||||
? 'Balcão'
|
||||
: 'Ponto de contacto institucional'}
|
||||
: {l.label} · {l.address}
|
||||
</p>
|
||||
<p>
|
||||
{l.territory_path?.map((n) => n.name).join(' / ') ||
|
||||
'Correspondência ao cadastro territorial por confirmar'}
|
||||
</p>
|
||||
<Source value={l} />
|
||||
</article>
|
||||
))}
|
||||
<h3>Produtos e programas</h3>
|
||||
{value.products.length === 0 && (
|
||||
<p>
|
||||
Produtos e condições por confirmar; a identificação da
|
||||
instituição não confirma oferta disponível.
|
||||
</p>
|
||||
)}
|
||||
{value.products.map((p) => (
|
||||
<article className={card} key={p.code}>
|
||||
<h4>{p.title}</h4>
|
||||
<p>{p.instrument}</p>
|
||||
<p>
|
||||
Cobertura do financiamento:{' '}
|
||||
{p.coverage === 'national'
|
||||
? 'Nacional, segundo a fonte'
|
||||
: p.coverage === 'territorial'
|
||||
? 'Locais documentados'
|
||||
: 'Por confirmar'}{' '}
|
||||
· {p.coverage_text}
|
||||
</p>
|
||||
{p.territory_paths?.map((path, i) => (
|
||||
<p key={i}>{path.map((n) => n.name).join(' / ')}</p>
|
||||
))}
|
||||
<p>Condições: {p.conditions || 'Por confirmar'}</p>
|
||||
<p>
|
||||
Montantes/moeda/prazos: {p.amounts || 'Por confirmar'}
|
||||
</p>
|
||||
<p>
|
||||
Disponibilidade:{' '}
|
||||
{p.availability === 'unknown'
|
||||
? 'Por confirmar'
|
||||
: p.availability === 'closed'
|
||||
? 'Encerrada segundo a fonte'
|
||||
: 'Oferta identificada na fonte; confirmar condições actuais com a instituição'}
|
||||
</p>
|
||||
{p.contact_url && (
|
||||
<a
|
||||
href={p.contact_url}
|
||||
className="underline"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Contactar/consultar o produto
|
||||
</a>
|
||||
)}
|
||||
<Source value={p} />
|
||||
</article>
|
||||
))}
|
||||
<p>
|
||||
Uma referência não é elegibilidade confirmada, aprovação nem
|
||||
garantia de financiamento. O portal não envia pedidos ou dados à
|
||||
instituição.
|
||||
</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -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}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) => (
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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}.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user