Adapt preparation presentation to declared applicability

This commit is contained in:
2026-10-23 13:53:02 +02:00
parent e1f010f941
commit 7ca94967f3
8 changed files with 88 additions and 10 deletions
+16 -6
View File
@@ -531,7 +531,7 @@ export default function InvestmentPath(path: Path) {
/>
)}
{!!path.investment_context?.opportunity_choices?.length && <OpportunityChoices choices={path.investment_context.opportunity_choices}/>}
<InvestmentRequirements assessment={path.investment_context?.requirements_assessment} contextId={path.case.id}/>
<InvestmentRequirements assessment={path.investment_context?.requirements_assessment} contextId={path.case.id} excludedSteps={path.steps.filter((step) => !step.preparation_allowed).map((step) => step.code)}/>
{!!path.content_sources?.length && (
<section
className="space-y-2 rounded-xl border p-4"
@@ -569,15 +569,14 @@ export default function InvestmentPath(path: Path) {
<h2 className="font-semibold">Próxima acção</h2>
{path.next ? (
<a className="underline" href={path.next.href}>
{path.next.action}: {path.next.code} · {path.next.title}
{path.next.action}: {path.next.title}
</a>
) : (
<p>Reveja as pendências e o acompanhamento.</p>
)}
<p className="text-sm">
Pode preparar etapas independentes enquanto aguarda
informação. Percurso v{path.definition_version}; os outros
roteiros mantêm a numeração original.
informação. As etapas abaixo adaptam-se às suas escolhas.
</p>
</section>
<nav
@@ -686,14 +685,25 @@ export default function InvestmentPath(path: Path) {
</button>
</form>
)}
{Object.entries(path.phases).map(([number, label]) => (
{path.steps.some((step) => !step.preparation_allowed) && (
<section className="rounded-xl border p-4" aria-label="Etapas sem aplicação">
<h2 className="font-semibold">Não precisa de preparar neste contexto</h2>
<ul>
{path.steps.filter((step) => !step.preparation_allowed).map((step) => (
<li key={step.code}>{step.title}: {step.reason || 'Conforme as escolhas guardadas.'}</li>
))}
</ul>
<p className="text-sm">Pode rever estas escolhas acima. Os dados e o histórico destas etapas ficam conservados.</p>
</section>
)}
{Object.entries(path.phases).filter(([number]) => path.steps.some((step) => step.phase === Number(number) && step.preparation_allowed)).map(([number, label]) => (
<section className="space-y-3" key={number}>
<h2 className="text-lg font-semibold">
Fase {number} · {label}
</h2>
<div className="grid items-start gap-3 md:grid-cols-2">
{path.steps
.filter((step) => step.phase === Number(number))
.filter((step) => step.phase === Number(number) && step.preparation_allowed)
.map((step) => (
<Stage
key={step.code}