import { Head, Link, usePage } from "@inertiajs/react"; import type { ReactNode } from "react"; import { PortalMenu } from "@/layouts/portal-navigation"; export type Option = { id: number; group: string; code: string; label: string; active: boolean; requires_description: boolean; sort_order: number; }; export type Entity = { id: string; name: string }; export type References = { zones?: { id: string; name: string; category: string }[]; options: Option[]; clusters: Entity[]; corridors: Entity[]; projects: Entity[]; locations: Entity[]; sectors: { id: number; name: string; slug: string }[]; }; export type Opportunity = { id: number; title: string; slug: string; reference: string; summary: string | null; description: string | null; province: string | null; district: string | null; sector?: { name: string; slug: string }; estimated_investment_amount: string | null; estimated_investment_currency: string; maturity_label: string | null; promoter_name: string | null; expected_impact: string | null; financing_modality: string | null; status: string; }; export type Context = { primary_territory_path?: { id: string; name: string; location_type: string }[]; zones?: { id: string; name: string; category: string; association_type: string; source_reference: string; }[]; profile: { version: number; is_education: boolean; business_model: string | null; requirements: string | null; risks: string | null; target_date: string | null; source_reference: string | null; } | null; facets: { id: number; group: string; label: string }[]; clusters: Entity[]; corridors: Entity[]; projects: Entity[]; locations: Entity[]; }; export const input = "w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-slate-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700"; export const button = "inline-flex items-center justify-center rounded-lg bg-emerald-800 px-4 py-2 font-semibold text-white disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-700"; export const card = "rounded-xl border border-slate-200 bg-white p-5 shadow-sm"; export function Frame({ title, children }: { title: string; children: ReactNode }) { const { flash } = usePage<{ flash?: { success?: string } }>().props; return (

{title}

{flash?.success && (

{flash.success}

)} {children}
); } export function Field({ label, children }: { label: string; children: ReactNode }) { return ( ); } export function money(r: Opportunity) { return r.estimated_investment_amount === null ? "Montante não indicado" : `${new Intl.NumberFormat("pt-MZ", { maximumFractionDigits: 2 }).format(Number(r.estimated_investment_amount))} ${r.estimated_investment_currency}`; } export async function api(url: string, body?: unknown) { const token = decodeURIComponent( document.cookie .split("; ") .find((c) => c.startsWith("XSRF-TOKEN=")) ?.slice(11) ?? "", ); const response = await fetch(url, { method: body === undefined ? "GET" : "POST", credentials: "same-origin", headers: { Accept: "application/json", "Content-Type": "application/json", "X-XSRF-TOKEN": token, }, ...(body === undefined ? {} : { body: JSON.stringify(body) }), }); const data = await response.json(); if (!response.ok) throw new Error(data.message ?? "Não foi possível concluir a operação."); return data; } export const groupLabels: Record = { education: "Educação", infrastructure: "Infraestruturas", labour: "Mão de obra", qualification: "Qualificações", support: "Apoios", impact: "Impacto", partnership: "Modelo de parceria", subsector: "Subsector", need_category: "Categoria da necessidade", priority: "Prioridade", unit: "Unidade", participation: "Participação", investor_profile: "Perfil do investidor", need_status: "Estado da necessidade", };