import React from 'react'; import { IonInput, IonLabel } from '@ionic/react'; import { sanitizeMoneyInput, getCurrencySymbol } from '../utils/money'; import { useAuth } from '../contexts/AuthContext'; interface MoneyInputProps { value: string; onValueChange: (value: string) => void; label?: string; placeholder?: string; error?: string; } const MoneyInput: React.FC = ({ value, onValueChange, label, placeholder = '0.00', error, }) => { const { profile } = useAuth(); const symbol = getCurrencySymbol(profile?.currency || 'USD'); const handleChange = (e: CustomEvent) => { const rawValue = e.detail.value || ''; const sanitized = sanitizeMoneyInput(rawValue); onValueChange(sanitized); }; return (
{label && ( {label} )}
{symbol}
{error && ( {error} )}
); }; export default MoneyInput;