import { getProjectReadiness, readPlannedRiskResponses, serializePlannedRiskResponses, type PlannedRiskResponse, type ReadinessDraft, } from '@/lib/project-readiness'; type Milestone = { title: string; due_date: string; status: string; planned_amount: string; actual_amount: string; }; function parseMilestones(value: string): Milestone[] { try { const parsed: unknown = JSON.parse(value || '[]'); return Array.isArray(parsed) ? parsed.filter((item): item is Milestone => Boolean( item && typeof item === 'object' && typeof item.title === 'string' && typeof item.due_date === 'string' && typeof item.planned_amount === 'string', ), ) : []; } catch { return []; } } const kindLabels = { missing: 'Informação em falta', unverified: 'Hipótese por verificar', risk: 'Risco identificado', }; export function ProjectReadiness({ draft, onChange, onNavigate, }: { draft: ReadinessDraft; onChange: (key: string, value: string) => void; onNavigate: (fieldKey: string) => void; }) { const items = getProjectReadiness(draft); const responses = readPlannedRiskResponses(draft); const milestones = parseMilestones( typeof draft.project_execution_snapshot === 'string' ? draft.project_execution_snapshot : '', ); const currency = typeof draft.currency === 'string' && draft.currency ? draft.currency : 'moeda ainda não indicada'; function updateResponse( riskId: string, patch: Partial, ) { const current = responses.find( (response) => response.risk_id === riskId, ) ?? { risk_id: riskId, action: '', owner: '', estimated_cost: '', due_date: '', }; const next = responses.filter( (response) => response.risk_id !== riskId, ); next.push({ ...current, ...patch }); onChange( 'project_risk_responses_snapshot', serializePlannedRiskResponses(next), ); } return (

O que precisa de esclarecer

Os avisos abaixo resultam apenas dos campos actualmente preenchidos. Não atribuem probabilidades, perdas ou uma classificação de viabilidade.

{items.length === 0 ? (

Não foram detectadas estas lacunas automáticas. Isto não confirma a qualidade, exactidão ou viabilidade do projecto.

) : (