Files
Investidor-V2/resources/js/components/investment-budget-range.tsx
T
Claude 4745331ebd
tests / ci (push) Canceled after 0s
Simulador: os campos numéricos aceitam «25.000», «1 500» e «1500,50»
O campo numérico do navegador segue a língua do navegador: «25.000» era
lido como 25 e a vírgula decimal podia ser recusada, pelo que o investidor
via o valor mudar ou não conseguia escrever. Os campos de montantes do
simulador, do plano de negócio e do orçamento inicial passam a usar um
campo de texto decimal que lê os números como se escrevem em Moçambique,
mostra «Lido como …» quando reinterpreta e deixa o texto inválido chegar à
validação, que o explica.

Os campos inteiros (horizonte, prazo de entrega, vida útil, mês económico)
deixam de saltar para 1 quando se apaga para reescrever; se o valor escrito
não for aceite, ao sair do campo volta o valor em vigor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
2026-12-04 23:01:57 +02:00

68 lines
2.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { DecimalInput } from '@/components/decimal-input';
import CurrencySelect from './currency-select';
/** A planning interval is not the amount used in a financial calculation. */
export default function InvestmentBudgetRange({
values,
onChange,
disabled = false,
}: {
values: Record<string, string>;
disabled?: boolean;
onChange?: (field: string, value: string) => void;
}) {
if (
!onChange &&
!values.investment_budget_min &&
!values.investment_budget_max
)
return null;
return (
<section className="grid gap-3 rounded border p-4">
<h3 className="font-semibold">Orçamento previsto</h3>
{onChange ? (
<>
<div className="grid gap-3 sm:grid-cols-2">
{(
[
'investment_budget_min',
'investment_budget_max',
] as const
).map((field, index) => (
<label key={field} className="grid gap-1">
{index === 0 ? 'Desde' : 'Até'}
<DecimalInput
className="min-w-0 rounded border p-2"
disabled={disabled}
min="0"
step="any"
value={values[field] ?? ''}
onValueChange={(value) =>
onChange(field, value)
}
/>
</label>
))}
</div>
<CurrencySelect
disabled={disabled}
label="Moeda do orçamento"
value={values.currency ?? ''}
onChange={(value) => onChange('currency', value)}
/>
</>
) : (
<p>
{values.investment_budget_min || 'Mínimo por indicar'} –{' '}
{values.investment_budget_max || 'Máximo por indicar'}{' '}
{values.currency}
</p>
)}
<p className="text-muted-foreground text-sm">
Este intervalo orienta a preparação. O valor de cada cenário de
investimento será indicado por si no simulador.
</p>
</section>
);
}