fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import {ProactiveSummary,proactiveView} from '@/components/proactive-investment';
|
||||
import {
|
||||
ProactiveSummary,
|
||||
proactiveView,
|
||||
} from '@/components/proactive-investment';
|
||||
import {
|
||||
PreparationSummary,
|
||||
type Preparation,
|
||||
@@ -97,7 +100,11 @@ function Result({ result }: { result: PathResult }) {
|
||||
const values = recoverPathResult(result);
|
||||
return (
|
||||
<li className="space-y-1 rounded border p-3">
|
||||
{result.context_opportunity && <p>Oportunidade desta análise: {result.context_opportunity}</p>}
|
||||
{result.context_opportunity && (
|
||||
<p>
|
||||
Oportunidade desta análise: {result.context_opportunity}
|
||||
</p>
|
||||
)}
|
||||
{result.context_state === 'review_required' && (
|
||||
<p
|
||||
role="status"
|
||||
@@ -124,8 +131,8 @@ function Result({ result }: { result: PathResult }) {
|
||||
</p>
|
||||
<p className="text-sm">
|
||||
Estimativa recalculada pelas fórmulas da ferramenta a partir
|
||||
dos dados preenchidos. Não
|
||||
constitui decisão de financiamento.
|
||||
dos dados preenchidos. Não constitui decisão de
|
||||
financiamento.
|
||||
</p>
|
||||
</li>
|
||||
);
|
||||
@@ -171,8 +178,14 @@ function Stage({ step, path }: { step: Step; path: Path }) {
|
||||
];
|
||||
const states = path.canWrite ? ownerStates : reviewStates;
|
||||
return (
|
||||
<details id={step.code} open={path.next?.code===step.code} className="space-y-3 rounded-xl border p-4">
|
||||
<summary className="cursor-pointer font-semibold">{step.title} · {pathStates[step.state]}</summary>
|
||||
<details
|
||||
id={step.code}
|
||||
open={path.next?.code === step.code}
|
||||
className="space-y-3 rounded-xl border p-4"
|
||||
>
|
||||
<summary className="cursor-pointer font-semibold">
|
||||
{step.title} · {pathStates[step.state]}
|
||||
</summary>
|
||||
<p>{pathStates[step.state]}</p>
|
||||
{step.context_review_required && (
|
||||
<label className="block rounded border border-amber-600 bg-amber-50 p-3">
|
||||
@@ -233,18 +246,32 @@ function Stage({ step, path }: { step: Step; path: Path }) {
|
||||
: action === 'operate'
|
||||
? 'Operação'
|
||||
: 'Execução'}{' '}
|
||||
aguarda {gaps.map(code=>path.steps.find(item=>item.code===code)?.title??code).join(', ')}. Pode continuar a preparar.
|
||||
aguarda{' '}
|
||||
{gaps
|
||||
.map(
|
||||
(code) =>
|
||||
path.steps.find(
|
||||
(item) => item.code === code,
|
||||
)?.title ?? code,
|
||||
)
|
||||
.join(', ')}
|
||||
. Pode continuar a preparar.
|
||||
</p>
|
||||
))}
|
||||
<details className="text-xs"><summary className="cursor-pointer underline">Fonte e referência desta etapa</summary><p>
|
||||
Referência interna {step.code}.{' '}
|
||||
Documento original, parágrafo {step.source_paragraph}.{' '}
|
||||
{step.detail.scope === 'internal_validation'
|
||||
? 'Conferência interna; não equivale a decisão externa.'
|
||||
: step.detail.scope === 'external_document_recorded'
|
||||
? 'Acto externo registado a partir de documento.'
|
||||
: 'Preparação declarada pelo promotor.'}
|
||||
</p></details>
|
||||
<details className="text-xs">
|
||||
<summary className="cursor-pointer underline">
|
||||
Fonte e referência desta etapa
|
||||
</summary>
|
||||
<p>
|
||||
Referência interna {step.code}. Documento original,
|
||||
parágrafo {step.source_paragraph}.{' '}
|
||||
{step.detail.scope === 'internal_validation'
|
||||
? 'Conferência interna; não equivale a decisão externa.'
|
||||
: step.detail.scope === 'external_document_recorded'
|
||||
? 'Acto externo registado a partir de documento.'
|
||||
: 'Preparação declarada pelo promotor.'}
|
||||
</p>
|
||||
</details>
|
||||
{step.preparation_allowed && (path.canWrite || path.canReview) && (
|
||||
<details>
|
||||
<summary className="cursor-pointer underline">
|
||||
@@ -433,7 +460,13 @@ export default function InvestmentPath(path: Path) {
|
||||
function support() {
|
||||
router.post(
|
||||
`/balcao-virtual/dossiers/${path.case.id}/pedidos`,
|
||||
{ service_version_id: service, client_key: requestKey, opportunity: new URLSearchParams(window.location.search).get('opportunity') },
|
||||
{
|
||||
service_version_id: service,
|
||||
client_key: requestKey,
|
||||
opportunity: new URLSearchParams(window.location.search).get(
|
||||
'opportunity',
|
||||
),
|
||||
},
|
||||
{ onError: (errors) => setError(Object.values(errors).join('; ')) },
|
||||
);
|
||||
}
|
||||
@@ -444,17 +477,56 @@ export default function InvestmentPath(path: Path) {
|
||||
Os meus investimentos
|
||||
</Link>
|
||||
<h1 className="text-2xl font-semibold">{path.case.title}</h1>
|
||||
{path.investment_context?.selection.portfolio && <p className="rounded border p-4">
|
||||
Origem documental: <Link className="underline" href={path.investment_context.selection.portfolio.href}>{path.investment_context.selection.portfolio.title}</Link>.
|
||||
{' '}A localização do investimento é escolhida no contexto.
|
||||
</p>}
|
||||
{!!path.opportunity_options?.length && <label className="block rounded border p-4">Oportunidade em tratamento
|
||||
<select className="ml-2 rounded border p-2" value={path.context_opportunity ?? ''} onChange={event => router.get(`/investimentos/${path.case.id}`, event.target.value ? {opportunity:event.target.value} : {}, {preserveState:false})}>
|
||||
<option value="">Escolha a oportunidade</option>
|
||||
{path.opportunity_options.map(choice => <option key={choice.opportunity.key} value={choice.opportunity.key}>{choice.opportunity.title} — {choice.territory?.title ?? 'Localização por definir'}</option>)}
|
||||
</select>
|
||||
{!path.context_opportunity && path.opportunity_options.length > 1 && <p>Escolha para consultar as etapas, os requisitos e o pedido de terra correspondentes. Os dados comuns conservam-se.</p>}
|
||||
</label>}
|
||||
{path.investment_context?.selection.portfolio && (
|
||||
<p className="rounded border p-4">
|
||||
Origem documental:{' '}
|
||||
<Link
|
||||
className="underline"
|
||||
href={path.investment_context.selection.portfolio.href}
|
||||
>
|
||||
{path.investment_context.selection.portfolio.title}
|
||||
</Link>
|
||||
. A localização do investimento é escolhida no contexto.
|
||||
</p>
|
||||
)}
|
||||
{!!path.opportunity_options?.length && (
|
||||
<label className="block rounded border p-4">
|
||||
Oportunidade em tratamento
|
||||
<select
|
||||
className="ml-2 rounded border p-2"
|
||||
value={path.context_opportunity ?? ''}
|
||||
onChange={(event) =>
|
||||
router.get(
|
||||
`/investimentos/${path.case.id}`,
|
||||
event.target.value
|
||||
? { opportunity: event.target.value }
|
||||
: {},
|
||||
{ preserveState: false },
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Escolha a oportunidade</option>
|
||||
{path.opportunity_options.map((choice) => (
|
||||
<option
|
||||
key={choice.opportunity.key}
|
||||
value={choice.opportunity.key}
|
||||
>
|
||||
{choice.opportunity.title} —{' '}
|
||||
{choice.territory?.title ??
|
||||
'Localização por definir'}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{!path.context_opportunity &&
|
||||
path.opportunity_options.length > 1 && (
|
||||
<p>
|
||||
Escolha para consultar as etapas, os requisitos
|
||||
e o pedido de terra correspondentes. Os dados
|
||||
comuns conservam-se.
|
||||
</p>
|
||||
)}
|
||||
</label>
|
||||
)}
|
||||
<ContextDocuments
|
||||
source={path.investment_context?.selection.opportunity}
|
||||
/>
|
||||
@@ -464,9 +536,7 @@ export default function InvestmentPath(path: Path) {
|
||||
/>
|
||||
{path.investment_context && (
|
||||
<section className="space-y-2 rounded border border-emerald-300 bg-emerald-50 p-4">
|
||||
<h2 className="font-semibold">
|
||||
As suas escolhas
|
||||
</h2>
|
||||
<h2 className="font-semibold">As suas escolhas</h2>
|
||||
{Object.values(path.investment_context.selection).map(
|
||||
(ref) => (
|
||||
<p key={ref.key}>
|
||||
@@ -503,9 +573,7 @@ export default function InvestmentPath(path: Path) {
|
||||
<Link className="underline" href={zone.href}>
|
||||
{zone.title}
|
||||
</Link>
|
||||
<p>
|
||||
{zone.selected_at}
|
||||
</p>
|
||||
<p>{zone.selected_at}</p>
|
||||
<p>{zone.notice}</p>
|
||||
</article>
|
||||
))}
|
||||
@@ -547,11 +615,38 @@ export default function InvestmentPath(path: Path) {
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{!!path.investment_context?.opportunity_choices?.length && <OpportunityChoices contextId={path.case.id} choices={path.investment_context.opportunity_choices}/>}
|
||||
{path.investment_context?.opportunity_choices?.map(choice=><ProactiveSummary key={choice.opportunity.key} value={proactiveView(choice.opportunity.analysis?.proactive)}/>)}
|
||||
{!path.investment_context?.opportunity_choices?.length&&<ProactiveSummary value={proactiveView(path.investment_context?.selection.opportunity?.analysis?.proactive)}/>}
|
||||
<SelectedComplements items={path.investment_context?.complements ?? []}/>
|
||||
<InvestmentRequirements assessment={path.investment_context?.requirements_assessment} contextId={path.case.id} excludedSteps={path.steps.filter((step) => !step.preparation_allowed).map((step) => step.code)}/>
|
||||
{!!path.investment_context?.opportunity_choices?.length && (
|
||||
<OpportunityChoices
|
||||
contextId={path.case.id}
|
||||
choices={path.investment_context.opportunity_choices}
|
||||
/>
|
||||
)}
|
||||
{path.investment_context?.opportunity_choices?.map((choice) => (
|
||||
<ProactiveSummary
|
||||
key={choice.opportunity.key}
|
||||
value={proactiveView(
|
||||
choice.opportunity.analysis?.proactive,
|
||||
)}
|
||||
/>
|
||||
))}
|
||||
{!path.investment_context?.opportunity_choices?.length && (
|
||||
<ProactiveSummary
|
||||
value={proactiveView(
|
||||
path.investment_context?.selection.opportunity?.analysis
|
||||
?.proactive,
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<SelectedComplements
|
||||
items={path.investment_context?.complements ?? []}
|
||||
/>
|
||||
<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"
|
||||
@@ -706,34 +801,68 @@ export default function InvestmentPath(path: Path) {
|
||||
</form>
|
||||
)}
|
||||
{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>
|
||||
<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>
|
||||
))}
|
||||
{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>
|
||||
<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]) => (
|
||||
<details open={path.steps.some(step=>step.phase===Number(number)&&step.code===path.next?.code)} className="space-y-3 rounded border p-4" key={number}>
|
||||
<summary className="cursor-pointer text-lg font-semibold">
|
||||
Fase {number} · {label}
|
||||
</summary>
|
||||
<div className="grid items-start gap-3 md:grid-cols-2">
|
||||
{path.steps
|
||||
.filter((step) => step.phase === Number(number) && step.preparation_allowed)
|
||||
.map((step) => (
|
||||
<Stage
|
||||
key={step.code}
|
||||
step={step}
|
||||
path={path}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
))}
|
||||
{Object.entries(path.phases)
|
||||
.filter(([number]) =>
|
||||
path.steps.some(
|
||||
(step) =>
|
||||
step.phase === Number(number) &&
|
||||
step.preparation_allowed,
|
||||
),
|
||||
)
|
||||
.map(([number, label]) => (
|
||||
<details
|
||||
open={path.steps.some(
|
||||
(step) =>
|
||||
step.phase === Number(number) &&
|
||||
step.code === path.next?.code,
|
||||
)}
|
||||
className="space-y-3 rounded border p-4"
|
||||
key={number}
|
||||
>
|
||||
<summary className="cursor-pointer text-lg font-semibold">
|
||||
Fase {number} · {label}
|
||||
</summary>
|
||||
<div className="grid items-start gap-3 md:grid-cols-2">
|
||||
{path.steps
|
||||
.filter(
|
||||
(step) =>
|
||||
step.phase === Number(number) &&
|
||||
step.preparation_allowed,
|
||||
)
|
||||
.map((step) => (
|
||||
<Stage
|
||||
key={step.code}
|
||||
step={step}
|
||||
path={path}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
))}
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-lg font-semibold">
|
||||
Resultados devolvidos ao dossier
|
||||
|
||||
Reference in New Issue
Block a user