versao compilada
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-15 17:37:00 +02:00
parent 9a96ee8dfe
commit c13f250b87
935 changed files with 210656 additions and 272 deletions
@@ -54,10 +54,25 @@ export default function BusinessInterest({
});
const [busy, setBusy] = useState(false);
const [error, setError] = useState('');
const [fieldErrors, setFieldErrors] = useState<Partial<Record<keyof Form, string>>>({});
const [receipt, setReceipt] = useState('');
const key = useRef(newSubmissionKey());
const update = <K extends keyof Form>(field: K, value: Form[K]) =>
const update = <K extends keyof Form>(field: K, value: Form[K]) => {
setForm((current) => ({ ...current, [field]: value }));
setFieldErrors((current) => ({ ...current, [field]: undefined }));
};
const fieldId = (field: keyof Form) => `business-interest-${field}`;
const feedback = (field: keyof Form) => ({
id: fieldId(field),
name: field,
'aria-invalid': !!fieldErrors[field],
'aria-describedby': fieldErrors[field] ? `${fieldId(field)}-error` : undefined,
});
const fieldError = (field: keyof Form) => fieldErrors[field] ? (
<p id={`${fieldId(field)}-error`} role="alert" className="text-sm text-red-700">
{fieldErrors[field]}
</p>
) : null;
const submit = async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
if (!form.privacyConsent) {
@@ -88,10 +103,20 @@ export default function BusinessInterest({
}),
});
const data = await response.json();
if (!response.ok)
throw new Error(
data.message ?? 'Não foi possível enviar a manifestação.',
);
if (!response.ok) {
const errors: Partial<Record<keyof Form, string>> = {};
for (const [field, messages] of Object.entries(data.errors ?? {})) {
if (field in form && Array.isArray(messages)) {
errors[field as keyof Form] = messages.filter((message): message is string => typeof message === 'string').join(' ');
}
}
setFieldErrors(errors);
setError(data.message ?? 'Não foi possível enviar a manifestação.');
const first = Object.keys(errors)[0] as keyof Form | undefined;
window.setTimeout(() => document.getElementById(first ? fieldId(first) : 'business-interest-feedback')?.focus(), 0);
return;
}
setFieldErrors({});
setReceipt(data.data.reference);
key.current = newSubmissionKey();
} catch (cause) {
@@ -123,9 +148,11 @@ export default function BusinessInterest({
</section>
) : (
<form className={`${card} space-y-4`} onSubmit={submit}>
<Field label="País de origem declarado desta solicitação">
<div className="space-y-1 text-sm font-medium"><span>País de origem declarado desta solicitação</span>
<CountrySelect
countries={countries}
id={fieldId('declared_origin_country_code')}
error={fieldErrors.declared_origin_country_code}
value={form.declared_origin_country_code}
label="País de origem declarado desta solicitação"
onChange={(value) =>
@@ -136,16 +163,18 @@ export default function BusinessInterest({
Origem opcional e independente do país do
investidor.
</p>
</Field>
</div>
<Field label="Nome ou denominação">
<input
className={input}
required
minLength={3}
maxLength={150}
{...feedback('fullName')}
value={form.fullName}
onChange={(e) => update('fullName', e.target.value)}
/>
{fieldError('fullName')}
</Field>
<Field label="Email">
<input
@@ -153,22 +182,27 @@ export default function BusinessInterest({
type="email"
required
maxLength={150}
{...feedback('email')}
value={form.email}
onChange={(e) => update('email', e.target.value)}
/>
{fieldError('email')}
</Field>
<Field label="Telefone">
<input
className={input}
type="tel"
maxLength={30}
{...feedback('phone')}
value={form.phone}
onChange={(e) => update('phone', e.target.value)}
/>
{fieldError('phone')}
</Field>
<Field label="Tipo de investidor">
<select
className={input}
{...feedback('investorType')}
value={form.investorType}
onChange={(e) =>
update('investorType', e.target.value)
@@ -182,32 +216,38 @@ export default function BusinessInterest({
</option>
<option value="outro">Outro</option>
</select>
{fieldError('investorType')}
</Field>
<Field label="País">
<div className="space-y-1 text-sm font-medium"><span>País</span>
<CountrySelect
countries={countries}
required
label="País do requerente"
allowLegacyValue
id={fieldId('country')}
error={fieldErrors.country}
value={form.country}
onChange={(value) => update('country', value)}
/>
</Field>
</div>
<Field label="Sector de interesse">
<input
className={input}
required
maxLength={150}
{...feedback('sectorInterest')}
value={form.sectorInterest}
onChange={(e) =>
update('sectorInterest', e.target.value)
}
/>
{fieldError('sectorInterest')}
</Field>
<Field label="Modalidade pretendida">
<select
className={input}
required
{...feedback('modality')}
value={form.modality}
onChange={(e) => update('modality', e.target.value)}
>
@@ -217,16 +257,19 @@ export default function BusinessInterest({
</option>
))}
</select>
{fieldError('modality')}
</Field>
<Field label="Intervalo de investimento">
<input
className={input}
maxLength={80}
{...feedback('investmentRange')}
value={form.investmentRange}
onChange={(e) =>
update('investmentRange', e.target.value)
}
/>
{fieldError('investmentRange')}
</Field>
<Field label="Motivação e pedido">
<textarea
@@ -235,14 +278,17 @@ export default function BusinessInterest({
minLength={20}
maxLength={2000}
rows={5}
{...feedback('message')}
value={form.message}
onChange={(e) => update('message', e.target.value)}
/>
{fieldError('message')}
</Field>
<label className="flex items-start gap-3">
<input
type="checkbox"
required
{...feedback('privacyConsent')}
checked={form.privacyConsent}
onChange={(e) =>
update('privacyConsent', e.target.checked)
@@ -271,7 +317,8 @@ export default function BusinessInterest({
equipa.
</span>
</label>
{error && <p role="alert">{error}</p>}
{fieldError('privacyConsent')}
{error && <p id="business-interest-feedback" tabIndex={-1} role="alert">{error}</p>}
<button className={button} disabled={busy}>
{busy ? 'A enviar…' : 'Enviar manifestação'}
</button>
@@ -272,6 +272,49 @@ export default function BusinessWizard({
publicTitle,
});
const dirty = serialized !== saved.current;
const submissionBlockers: string[] = [];
if (busy)
submissionBlockers.push(
t('Aguarde que a gravação termine.', 'Wait for saving to finish.'),
);
if (!consent)
submissionBlockers.push(
t(
'Marque a confirmação de exactidão e autorização de análise interna, junto ao código.',
'Check the accuracy and internal review consent box beside the code.',
),
);
if (confirmation !== record.code)
submissionBlockers.push(
confirmation.trim() === record.code
? t(
'Retire os espaços antes ou depois do código MNE.',
'Remove spaces before or after the MNE code.',
)
: t(
'Introduza o código MNE completo mostrado no topo desta página, incluindo MNE- e os hífenes.',
'Enter the full MNE code shown at the top of this page, including MNE- and the hyphens.',
),
);
for (const [key, pt, en] of [
[
'confirm_information',
'Confirme que a informação corresponde ao que conhece.',
'Confirm that the information reflects your knowledge.',
],
[
'confirm_disclosure_authority',
'Confirme que tem autorização para apresentar a oportunidade e divulgar os conteúdos seleccionados.',
'Confirm your authority to present the opportunity and disclose the selected content.',
],
[
'confirm_no_publication_guarantee',
'Confirme que compreende que a submissão não constitui publicação, aprovação oficial ou garantia de investimento.',
'Confirm that submission does not constitute publication, official approval or an investment guarantee.',
],
]) {
if (payload[key] !== 'yes') submissionBlockers.push(t(pt, en));
}
const save = useCallback(async () => {
if (inFlight.current) return false;
if (serialized === saved.current) return true;
@@ -1126,10 +1169,41 @@ export default function BusinessWizard({
onChange={(e) =>
setConfirmation(e.target.value)
}
aria-describedby="business-submission-requirements"
/>
</Field>
<div
id="business-submission-requirements"
role="status"
aria-live="polite"
className="rounded border p-3"
>
{submissionBlockers.length > 0 ? (
<>
<p className="font-semibold">
{t(
'Para disponibilizar o botão de submissão:',
'To enable the submission button:',
)}
</p>
<ul className="list-disc pl-6">
{submissionBlockers.map((message) => (
<li key={message}>{message}</li>
))}
</ul>
</>
) : (
<p>
{t(
'Confirmações preenchidas. Pode submeter para análise.',
'Confirmations completed. You can submit for review.',
)}
</p>
)}
</div>
<button
className={button}
aria-describedby="business-submission-requirements"
disabled={
busy ||
!consent ||
@@ -226,6 +226,7 @@ function Editor({
className={input}
value={note}
onChange={(e) => setNote(e.target.value)}
aria-describedby="business-transition-help"
minLength={10}
maxLength={1000}
required
@@ -257,6 +258,15 @@ function Editor({
designados. Esta autorização não permite publicação.
</label>
)}
{(canTriage || canReview || canApproveLevelOne || canApproveLevelTwo || canPublish) && (
<p id="business-transition-help" role="status" className="my-3">
{busy
? 'Aguarde a conclusão da ação em curso.'
: note.trim().length < 10
? 'Para disponibilizar a ação, preencha «Motivo da alteração ou nota para a revisão» com pelo menos 10 caracteres. A nota fica no histórico reservado.'
: 'Nota preenchida. Pode executar a ação disponível para o seu papel e o estado atual.'}
</p>
)}
<div className="flex flex-wrap gap-3">
{owner && canEdit && (
<button
@@ -291,6 +301,7 @@ function Editor({
<button
className={button}
disabled={busy || note.trim().length < 10}
aria-describedby="business-transition-help"
onClick={() => void run('triage')}
>
Iniciar triagem
+14 -2
View File
@@ -521,18 +521,30 @@ export default function Catalogue({
<Field label="Estado de preparação">
<select
className={input}
aria-describedby="maturity-catalogue-note"
value={form.data.maturity_level}
onChange={(e) =>
form.setData('maturity_level', e.target.value)
}
>
<option value="">Todos os níveis</option>
{MATURITY_LEVELS.map((label, index) => (
{(references.maturityCatalogue
? Object.values(references.maturityCatalogue.stages)
: MATURITY_LEVELS
).map((label, index) => (
<option key={index + 1} value={index + 1}>
{label}
{references.maturityCatalogue
? `${index + 1} — ${references.maturityCatalogue.legacyLabels[index + 1] ? `${references.maturityCatalogue.legacyLabels[index + 1]} (${references.maturityCatalogue.legacyVersion}) / ` : ''}${label} (${references.maturityCatalogue.version})`
: label}
</option>
))}
</select>
<p id="maturity-catalogue-note" className="text-sm">
O filtro usa a posição registada. Os catálogos
histórico e V2 conservam significados distintos nas
posições 1–6; consulte a maturidade apresentada na
ficha. As posições 7–8 pertencem ao catálogo V2.
</p>
</Field>
{(['min_amount', 'max_amount'] as const).map((key) => (
<Field
+8
View File
@@ -174,6 +174,14 @@ export default function Detail({
['Promotor', r.promoter_name],
['Investimento', money(r)],
['Maturidade', r.maturity_label],
[
'Catálogo de maturidade',
r.maturity_catalogue_version === 'spec-v2'
? 'Oito etapas (V2)'
: r.maturity_catalogue_version === 'legacy-v1'
? 'Histórico — seis níveis'
: 'Versão não registada',
],
['Parceria', r.financing_modality],
['Impacto', r.expected_impact],
['Calendário', c.profile?.target_date],
+7
View File
@@ -23,6 +23,12 @@ export type Entity = {
geography?: StructureGeography | null;
};
export type References = {
maturityCatalogue?: {
version: string;
stages: Record<string, string>;
legacyVersion: string;
legacyLabels: Record<number, string>;
};
zones?: { id: string; name: string; category: string }[];
options: Option[];
clusters: Entity[];
@@ -44,6 +50,7 @@ export type Opportunity = {
estimated_investment_amount: string | null;
estimated_investment_currency: string;
maturity_label: string | null;
maturity_catalogue_version?: string | null;
promoter_name: string | null;
expected_impact: string | null;
financing_modality: string | null;