import { readRows, type ProjectMilestone, type TeamNeed, } from '@/lib/project-dossier'; import { restoreBusinessPlanSnapshot } from '@/lib/business-financial-plan'; import { buildComplementaryTables } from '@/lib/complementary-report'; import { InvestmentReportTables } from './investment-report-tables'; const teamKeys = [ 'competency', 'state', 'action', 'estimated_cost', 'due_date', ] as const; const milestoneKeys = [ 'title', 'due_date', 'status', 'planned_amount', 'actual_amount', ] as const; function update>( rows: T[], index: number, key: keyof T, value: string, ): T[] { return rows.map((row, i) => (i === index ? { ...row, [key]: value } : row)); } function unreadable(value: string, rows: unknown[], optional: string[]) { try { const parsed: unknown = JSON.parse(value || '[]'); return ( !Array.isArray(parsed) || parsed.length !== rows.length || parsed.length > 100 || parsed.some((row) => optional.some( (key) => key in row && typeof row[key] !== 'string', ), ) ); } catch { return true; } } function SupplementaryFields({ row, fields, change, }: { row: Record; fields: readonly (readonly [string, string, string])[]; change: (key: string, value: string) => void; }) { return ( <> {fields.map(([key, label, type]) => ( ))} ); } export function ProjectTeamPlanner({ value, onChange, financialPlanSnapshot = '', projectCurrency = '', }: { value: string; onChange: (value: string) => void; financialPlanSnapshot?: string; projectCurrency?: string; }) { const rows = readRows(value, teamKeys); const persist = (next: TeamNeed[]) => onChange(JSON.stringify(next)); if ( unreadable(value, rows, [ 'department', 'quantity', 'monthly_salary', 'start_month', 'end_month', ]) ) return (

O plano de equipa guardado contém linhas não reconhecidas. O original foi preservado e não será substituído por este editor.

); return (

Registe competências declaradas, lacunas, resposta prevista, custo e prazo. Não é uma certificação nem uma correspondência automática a prestadores.

Para o mapa de pessoal: função, departamento, quantidade, remuneração mensal e meses inicial/final são necessários. Os restantes campos são opcionais; não confundir custo de formação ou contratação com salário.

{rows.map((row, index) => (
Necessidade {index + 1} persist( update( rows, index, key as keyof TeamNeed, value, ), ) } />
))}
); } export function ProjectMilestonePlanner({ value, onChange, }: { value: string; onChange: (value: string) => void; }) { const rows = readRows(value, milestoneKeys); const persist = (next: ProjectMilestone[]) => onChange(JSON.stringify(next)); if (unreadable(value, rows, ['start_date', 'responsible', 'department'])) return (

O plano de marcos guardado contém linhas não reconhecidas. O original foi preservado e não será substituído por este editor.

); return (

Compare datas e montantes planeados com o realizado. Estes valores são declarados; não alteram automaticamente o plano financeiro.

Para completar o relatório, indique título, início, término, responsável, departamento e orçamento. O montante realizado é opcional.

{rows.map((row, index) => (
Marco {index + 1} persist( update( rows, index, key as keyof ProjectMilestone, value, ), ) } />
))}
); }