import { InstitutionView, type InstitutionDetails } from "@/components/funding-institution"; import { financialCategories, financialTypes } from "@/components/funding-classification"; import { Link, useForm } from "@inertiajs/react"; import { Frame, card, button } from "@/pages/investment/shared"; import { type Programme, windowLabels } from "./shared"; import { useRef, useState } from "react"; import { TerritoryFields, type TerritoryOption } from "@/components/investment-territory"; export default function FundingIndex(props: Parameters[0]) { return ; } function Index({ items, filters, kinds, management, options, needs = {}, categoryTypes = {}, territorySelection = [], criteriaErrors = {}, }: { items: { data: Programme[]; links: { url: string | null; label: string; active: boolean }[]; }; filters: { q?: string; kind?: string; sector?: string; territory?: string; certainty?: string; state?: string; need?: string; context?: string; opportunity?: string; category?: string; institution_type?: string; location_mode?: string; include_historical?: string; province_id?: string; district_id?: string; admin_post_id?: string; locality_id?: string; }; options: { sectors: { id: number; name: string }[]; territories: { id: string; name: string }[]; }; kinds: Record; needs?: Record; management: boolean; categoryTypes?: Record; territorySelection?: TerritoryOption[]; criteriaErrors?: Record; }) { const [notice, setNotice] = useState(""); const form = useForm({ category: filters.category ?? "", institution_type: filters.institution_type ?? "", location_mode: filters.location_mode ?? "coverage", include_historical: filters.include_historical ?? "0", context: filters.context ?? "", opportunity: filters.opportunity ?? "", need: filters.need ?? "", q: filters.q ?? "", kind: filters.kind ?? "", sector: filters.sector ?? "", territory: filters.territory ?? "", province_id: filters.province_id ?? "", district_id: filters.district_id ?? "", admin_post_id: filters.admin_post_id ?? "", locality_id: filters.locality_id ?? "", certainty: filters.certainty ?? (filters.location_mode === "physical" ? "documented" : "include_unknown"), state: filters.state ?? "", }); const applied = useRef(JSON.stringify(form.data)); const criteriaChanged = JSON.stringify(form.data) !== applied.current; const typeAllowed = (category: string, type: string) => !category || category === "other" || !type || type === "other" || (categoryTypes[category] ?? []).includes(type); return ( {management && ( Gerir fundos e programas )} A minha selecção

Encontre bancos, seguradoras, fundos e outros parceiros financeiros. Explore as soluções e os contactos adequados ao seu investimento.

label]:w-full [&>label]:max-w-full [&>label]:min-w-0 sm:[&>label]:w-auto`} onSubmit={(e) => { e.preventDefault(); form.get("/fundos"); }} > {Object.keys(criteriaErrors).length > 0 && ( )} {notice && (

{notice}

)} {Object.entries(form.errors).map(([key, error]) => (

{error}

))} {form.data.kind && form.data.kind !== "institution" && (form.data.category || form.data.institution_type || form.data.location_mode === "physical") && ( )}
Local de interesse — seleccione até ao nível conhecido

Escolha a província e, se necessário, o distrito. Sede e balcões identificam onde pode contactar a instituição; a cobertura indica onde o financiamento se aplica.

form.setData({ ...form.data, territory: path.at(-1)?.id ?? "", province_id: path.find((node) => node.location_type === "province")?.id ?? "", district_id: path.find((node) => node.location_type === "district")?.id ?? "", admin_post_id: path.find((node) => node.location_type === "admin_post")?.id ?? "", locality_id: path.find((node) => node.location_type === "locality")?.id ?? "", }) } />
{criteriaChanged && (

Alterou os critérios. Clique em Pesquisar para os aplicar. Os resultados anteriores ficam separados abaixo.

)}
{Object.keys(criteriaErrors).length ? "Pesquisa não executada — critérios inválidos" : criteriaChanged ? "Resultados da pesquisa anterior — não correspondem aos critérios por aplicar" : "Resultados correspondentes à pesquisa"}

Explore as instituições e soluções adequadas ao seu investimento. Use os filtros para encontrar a informação de que precisa.

{items.data.length === 0 && Object.keys(criteriaErrors).length === 0 && (

Não foram encontradas instituições, fundos ou programas publicados que correspondam a todos os critérios desta pesquisa.

)} {items.data.map((item) => (

typeof entry[1] === "string"))}`} > {item.payload.title}

{item.payload.kind === "institution" ? ( ) : ( <>

{item.payload.summary}

Entidade gestora: {item.payload.manager_name}

{Object.entries(item.filter_explanation ?? {}).map( ([key, message]) => (

{message}

), )} )} {item.payload.kind === "institution" && item.payload.windows.length === 0 ? null : item.payload.windows.length === 0 ? (

Não existe uma janela de candidatura confirmada para este programa.

) : (
    {item.payload.windows.map((window) => (
  • {window.title}: {windowLabels[window.state]}
  • ))}
)}
))}
); }