novas funcionalidades dos formulario
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-02 11:13:37 +02:00
parent a6afb4e97a
commit 4f35313d06
104 changed files with 7653 additions and 178 deletions
+2 -99
View File
@@ -3,6 +3,7 @@ import { useState } from "react";
import { PortalMenu } from "@/layouts/portal-navigation";
import { newSubmissionKey } from "@/lib/portal-api";
import { ProvinceSelect } from "@/components/investment-territory";
import { SimulationForm } from "@/components/simulation-form";
const input = "w-full rounded-lg border border-slate-300 bg-white p-3 text-slate-900";
const button =
@@ -293,105 +294,7 @@ function PartnershipForm() {
}
function Simulator() {
const [base, setBase] = useState("");
const [rate, setRate] = useState("");
const [reduction, setReduction] = useState("0");
const [currency, setCurrency] = useState("MZN");
const valid =
base !== "" &&
rate !== "" &&
reduction !== "" &&
Number.isFinite(Number(base)) &&
Number(base) >= 0 &&
Number(base) <= 1e12 &&
Number(rate) >= 0 &&
Number(rate) <= 100 &&
Number(reduction) >= 0 &&
Number(reduction) <= 100;
const gross = (Number(base) * Number(rate)) / 100;
const net = gross * (1 - Number(reduction) / 100);
const format = (n: number) =>
new Intl.NumberFormat("pt-MZ", { style: "currency", currency }).format(n);
return (
<section className="max-w-2xl space-y-5 rounded-xl border bg-white p-6">
<h2 className="text-xl font-bold">Cenário com parâmetros próprios</h2>
<p>
Introduza uma base tributável e uma taxa que pretende comparar. Não existem taxas
legais ou incentivos automáticos neste cálculo; a redução é uma hipótese introduzida
por si.
</p>
<label className="block">
Moeda
<select
className={input}
value={currency}
onChange={(e) => setCurrency(e.target.value)}
>
{["MZN", "USD", "EUR", "ZAR"].map((c) => (
<option key={c}>{c}</option>
))}
</select>
</label>
<label className="block">
Base tributável
<input
className={input}
type="number"
min="0"
max="1000000000000"
step="0.01"
value={base}
onChange={(e) => setBase(e.target.value)}
/>
</label>
<label className="block">
Taxa a simular (%)
<input
className={input}
type="number"
min="0"
max="100"
step="0.01"
value={rate}
onChange={(e) => setRate(e.target.value)}
/>
</label>
<label className="block">
Redução hipotética do imposto (%)
<input
className={input}
type="number"
min="0"
max="100"
step="0.01"
value={reduction}
onChange={(e) => setReduction(e.target.value)}
/>
</label>
<div role="status" className="rounded bg-emerald-50 p-5">
{valid ? (
<>
<p>
Sem redução: <strong>{format(gross)}</strong>
</p>
<p>Redução simulada: {format(gross - net)}</p>
<p>
Total do cenário: <strong>{format(net)}</strong>
</p>
<p className="mt-3 text-sm">
Base × taxa ÷ 100 × (1 − redução ÷ 100). Não inclui outros impostos,
deduções, escalões ou regras sectoriais.
</p>
</>
) : (
<p>Preencha a base e uma taxa válida entre 0 e 100%.</p>
)}
</div>
<Link href="/apoio" className="underline">
Pedir esclarecimento sobre o enquadramento aplicável
</Link>
</section>
);
return <SimulationForm />;
}
export default function Services(p: Props) {