Files
Investidor-V2/resources/js/components/investment-budget-range.tsx
T

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 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é'}
<input
className="min-w-0 rounded border p-2"
disabled={disabled}
type="number"
min="0"
step="any"
value={values[field] ?? ''}
onChange={(event) =>
onChange(field, event.target.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>
);
}