import type { BusinessFinancialPlanInput } from '@/lib/business-financial-plan'; import { buildComplementaryTables, isMarketAnalysis, } from '@/lib/complementary-report'; import { InvestmentReportTables } from './investment-report-tables'; export function MarketAnalysisPlan({ plan, onChange, }: { plan: BusinessFinancialPlanInput; onChange: (p: BusinessFinancialPlanInput) => void; }) { const a = plan.marketAnalysis ?? { baseYear: plan.reportAssumptions?.startYear ?? '', years: '3', segments: [], }; if (!isMarketAnalysis(a)) return (

A análise de mercado guardada tem uma estrutura desconhecida. Foi preservada; reveja o ficheiro antes de editar.

); const update = (patch: Partial) => onChange({ ...plan, marketAnalysis: { ...a, ...patch } }); const input = ( label: string, value: string, change: (v: string) => void, type = 'text', ) => ( ); return (
Análise de Mercado — segmentos e hipóteses

Obrigatório para completar esta tabela: ano-base, horizonte de 2 a 10 anos e, por segmento, nome, clientes potenciais inteiros, crescimento anual e fonte ou hipótese identificada. Não são vendas nem procura confirmada. O horizonte sugerido de três anos é editável; não representa dados económicos.

{input( 'Ano-base de mercado', a.baseYear, (v) => update({ baseYear: v }), 'number', )} {input( 'Horizonte de mercado (anos)', a.years, (v) => update({ years: v }), 'number', )}
{a.segments.map((s, i) => (
Segmento {i + 1} {( [ ['label', 'Nome do segmento', 'text'], [ 'customers', 'Clientes potenciais no ano-base', 'number', ], [ 'growthPercent', 'Crescimento anual do segmento (%)', 'number', ], [ 'basis', 'Fonte e data, ou hipótese ilustrativa', 'text', ], ] as const ).map(([key, label, type]) => (
{input( label, s[key], (v) => update({ segments: a.segments.map((r, j) => j === i ? { ...r, [key]: v } : r, ), }), type, )}
))}
))}
); }