commit compras2 2811
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-28 15:45:52 +02:00
parent eb32c74c56
commit 060c119ba1
92 changed files with 4936 additions and 43 deletions
@@ -46,6 +46,20 @@ type Page<T> = {
next_page_url: string | null;
};
type Props = {
referenceDraftWarnings?: { source_id: number; message: string }[];
referenceDrafts?: {
source_id: number;
code: string;
description: string;
rate_percent: string;
title: string;
official_reference: string;
official_url: string | null;
citation: string;
valid_from: string;
obligations: string;
charges: LegalCharge[];
}[];
sources?: Page<{
id: number;
data: { official_reference: string; official_url: string | null };
@@ -864,6 +878,87 @@ export default function ImportLegal(props: Props) {
: 'Preparar uma regra documentada'
}
>
{props.referenceDraftWarnings?.map((warning) => (
<p
key={warning.source_id}
role="status"
className="mb-3 text-sm"
>
Fonte #{warning.source_id}: {warning.message}
</p>
))}
{(props.referenceDrafts?.length ?? 0) > 0 && (
<div className="mb-5 space-y-3 rounded border p-3">
<h3 className="font-medium">
Preparar a partir do exemplar oficial
</h3>
<p className="text-sm">
Transcrição da página 2180-(4) da Lei 8/2025,
com início em 01/01/2026. Inclui apenas a taxa
geral dessa edição; não é uma pauta consolidada
nem determina isenções, preferências ou outras
imposições. A preparação continua editável e
exige gravação e decisão expressas.
</p>
{form.isDirty && (
<p className="text-sm">
Conclua ou limpe a preparação actual antes
de escolher outro código. O preenchimento
existente será conservado.
</p>
)}
<div className="grid gap-2">
{props.referenceDrafts?.map((draft) => (
<Button
key={`${draft.source_id}:${draft.code}`}
type="button"
variant="outline"
className="h-auto justify-start text-left whitespace-normal"
disabled={
form.isDirty ||
form.processing ||
form.data.record_key !== null
}
onClick={() => {
form.setData({
...form.data,
operation_key: '',
record_key: null,
version: 0,
action: 'save',
title: draft.title,
official_reference:
draft.official_reference,
official_url:
draft.official_url ?? '',
citation: draft.citation,
valid_from: draft.valid_from,
valid_until: '',
match_code: draft.code,
suggested_code: draft.code,
origin_country: '',
sector: '',
obligations: draft.obligations,
document_types: [],
reason: '',
file: null,
source_id: String(
draft.source_id,
),
charges: chargeDrafts(
draft.charges,
),
});
form.clearErrors();
}}
>
{draft.code} — {draft.description} —
taxa geral {draft.rate_percent}%
</Button>
))}
</div>
</div>
)}
<form
ref={ref}
className="space-y-4"