vrsao 2
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-08 14:02:01 +02:00
parent bdd766c68a
commit 1106509116
354 changed files with 48275 additions and 24635 deletions
+77 -40
View File
@@ -1,6 +1,6 @@
import { Head, Link, usePage } from "@inertiajs/react";
import type { ReactNode } from "react";
import { PortalMenu } from "@/layouts/portal-navigation";
import { Head, Link, usePage } from '@inertiajs/react';
import type { ReactNode } from 'react';
import { PortalMenu } from '@/layouts/portal-navigation';
import type { StructureGeography } from '@/components/structure-geography';
export type Option = {
@@ -12,7 +12,12 @@ export type Option = {
requires_description: boolean;
sort_order: number;
};
export type Entity = { id: string; name: string; dossiers?: { id: string; title: string; source: string }[]; geography?: StructureGeography | null };
export type Entity = {
id: string;
name: string;
dossiers?: { id: string; title: string; source: string }[];
geography?: StructureGeography | null;
};
export type References = {
zones?: { id: string; name: string; category: string }[];
options: Option[];
@@ -42,7 +47,11 @@ export type Opportunity = {
last_validated_at?: string | null;
};
export type Context = {
primary_territory_path?: { id: string; name: string; location_type: string }[];
primary_territory_path?: {
id: string;
name: string;
location_type: string;
}[];
zones?: {
id: string;
name: string;
@@ -66,18 +75,34 @@ export type Context = {
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";
'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;
'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; warning?: string };
}>().props;
return (
<div className="min-h-screen bg-slate-50 text-slate-900">
<Head title={title} />
<PortalMenu />
<main className="mx-auto max-w-7xl space-y-6 px-5 py-9">
<h1 className="text-3xl font-bold">{title}</h1>
{flash?.warning && (
<p
role="alert"
className="rounded border border-amber-600 bg-amber-50 p-4 text-amber-950"
>
{flash.warning}
</p>
)}
{flash?.success && (
<p
role="status"
@@ -91,8 +116,8 @@ export function Frame({ title, children }: { title: string; children: ReactNode
<footer className="border-t p-6 text-center">
<Link href="/apoio" className="underline">
Apoio ao Investidor
</Link>{" "}
·{" "}
</Link>{' '}
·{' '}
<Link href="/documentos" className="underline">
Documentos
</Link>
@@ -100,7 +125,13 @@ export function Frame({ title, children }: { title: string; children: ReactNode
</div>
);
}
export function Field({ label, children }: { label: string; children: ReactNode }) {
export function Field({
label,
children,
}: {
label: string;
children: ReactNode;
}) {
return (
<label className="block space-y-1 text-sm font-medium">
<span>{label}</span>
@@ -110,44 +141,50 @@ export function Field({ label, children }: { label: string; children: ReactNode
}
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}`;
? '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) ?? "",
.split('; ')
.find((c) => c.startsWith('XSRF-TOKEN='))
?.slice(11) ?? '',
);
const formData = typeof FormData !== "undefined" && body instanceof FormData;
const formData =
typeof FormData !== 'undefined' && body instanceof FormData;
const response = await fetch(url, {
method: body === undefined ? "GET" : "POST",
credentials: "same-origin",
method: body === undefined ? 'GET' : 'POST',
credentials: 'same-origin',
headers: {
Accept: "application/json",
...(formData ? {} : { "Content-Type": "application/json" }),
"X-XSRF-TOKEN": token,
Accept: 'application/json',
...(formData ? {} : { 'Content-Type': 'application/json' }),
'X-XSRF-TOKEN': token,
},
...(body === undefined ? {} : { body: formData ? body : JSON.stringify(body) }),
...(body === undefined
? {}
: { body: formData ? 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.");
if (!response.ok)
throw new Error(
data.message ?? 'Não foi possível concluir a operação.',
);
return data;
}
export const groupLabels: Record<string, string> = {
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",
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',
};