fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -2,21 +2,77 @@ import { Link } from '@inertiajs/react';
|
||||
import type { RequirementsAssessment } from '@/lib/investor-context';
|
||||
import { card } from '@/pages/investment/shared';
|
||||
|
||||
export default function InvestmentRequirements({assessment, contextId, excludedSteps = []}: {assessment?: RequirementsAssessment | null; contextId: string; excludedSteps?: string[]}) {
|
||||
export default function InvestmentRequirements({
|
||||
assessment,
|
||||
contextId,
|
||||
excludedSteps = [],
|
||||
}: {
|
||||
assessment?: RequirementsAssessment | null;
|
||||
contextId: string;
|
||||
excludedSteps?: string[];
|
||||
}) {
|
||||
if (!assessment?.requirements.length) return null;
|
||||
const labels: Record<string,string> = {selected:'Localização escolhida; direito não inferido',missing:'Informação em falta',conditional:'Conforme as condições do projecto',declared:'Actividades declaradas; enquadrar modalidade',undetermined:'Procedimento específico por determinar'};
|
||||
const labels: Record<string, string> = {
|
||||
selected: 'Localização escolhida; direito não inferido',
|
||||
missing: 'Informação em falta',
|
||||
conditional: 'Conforme as condições do projecto',
|
||||
declared: 'Actividades declaradas; enquadrar modalidade',
|
||||
undetermined: 'Procedimento específico por determinar',
|
||||
};
|
||||
const groups = new Map<string, RequirementsAssessment['requirements']>();
|
||||
for (const row of assessment.requirements) {
|
||||
if (excludedSteps.includes(row.step)) continue;
|
||||
groups.set(row.opportunity_key,[...(groups.get(row.opportunity_key)??[]),row]);
|
||||
groups.set(row.opportunity_key, [
|
||||
...(groups.get(row.opportunity_key) ?? []),
|
||||
row,
|
||||
]);
|
||||
}
|
||||
return <section className="space-y-4" aria-label="Regras e documentos por oportunidade"><h2 className="text-xl font-bold">Requisitos por oportunidade e contexto</h2>
|
||||
<p>{assessment.fiscal_notice}</p>
|
||||
{[...groups.entries()].map(([key, rows])=><details key={key} className={card}><summary className="cursor-pointer font-semibold">{rows[0].opportunity_title} · {rows.length} aspectos a conferir</summary>{rows.map(r=><article key={r.opportunity_key+':'+r.code} className="my-3 space-y-2 border-t pt-3">
|
||||
<h3 className="font-semibold">{r.title} — {r.opportunity_title}</h3><p>{labels[r.state] ?? r.state}</p><p>Entidade: {r.authority}</p><p>{r.basis}</p>
|
||||
<ul className="list-disc pl-5">{r.documents.map(d=><li key={d}>{d}</li>)}</ul>
|
||||
<a className="underline" href={r.source_url}>Consultar fundamento e procedimento</a>{' · '}<Link className="underline" href={`/investimentos/${contextId}?opportunity=${encodeURIComponent(r.opportunity_key)}#${r.step}`}>Preparar e acompanhar em {r.step}</Link>
|
||||
<p>{r.decision}</p>
|
||||
</article>)}</details>)}
|
||||
</section>;
|
||||
return (
|
||||
<section
|
||||
className="space-y-4"
|
||||
aria-label="Regras e documentos por oportunidade"
|
||||
>
|
||||
<h2 className="text-xl font-bold">
|
||||
Requisitos por oportunidade e contexto
|
||||
</h2>
|
||||
<p>{assessment.fiscal_notice}</p>
|
||||
{[...groups.entries()].map(([key, rows]) => (
|
||||
<details key={key} className={card}>
|
||||
<summary className="cursor-pointer font-semibold">
|
||||
{rows[0].opportunity_title} · {rows.length} aspectos a
|
||||
conferir
|
||||
</summary>
|
||||
{rows.map((r) => (
|
||||
<article
|
||||
key={r.opportunity_key + ':' + r.code}
|
||||
className="my-3 space-y-2 border-t pt-3"
|
||||
>
|
||||
<h3 className="font-semibold">
|
||||
{r.title} — {r.opportunity_title}
|
||||
</h3>
|
||||
<p>{labels[r.state] ?? r.state}</p>
|
||||
<p>Entidade: {r.authority}</p>
|
||||
<p>{r.basis}</p>
|
||||
<ul className="list-disc pl-5">
|
||||
{r.documents.map((d) => (
|
||||
<li key={d}>{d}</li>
|
||||
))}
|
||||
</ul>
|
||||
<a className="underline" href={r.source_url}>
|
||||
Consultar fundamento e procedimento
|
||||
</a>
|
||||
{' · '}
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/investimentos/${contextId}?opportunity=${encodeURIComponent(r.opportunity_key)}#${r.step}`}
|
||||
>
|
||||
Preparar e acompanhar em {r.step}
|
||||
</Link>
|
||||
<p>{r.decision}</p>
|
||||
</article>
|
||||
))}
|
||||
</details>
|
||||
))}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user