import { FormInline, Input, Select } from '@/components' import type { TokenSymbol } from '@/types' import type { Dispatch, SetStateAction } from 'react' export function FormAmount({ amount, setAmount, token, setToken, isFiat }: { amount: number setAmount: Dispatch> token: TokenSymbol | string setToken?: Dispatch> isFiat?: boolean }) { function handleAmountChange(e: React.ChangeEvent) { const { value } = e.target if (value === '') { setAmount(0) } else if (Number.isNaN(Number(value))) { return } else { setAmount(Number(value)) } } function handleTokenChange(e: React.ChangeEvent) { if (!setToken) return setToken(e.target.value as TokenSymbol) } function handleFocus(e: React.FocusEvent) { e.target.select() } const options = isFiat ? [{ value: 'USD', label: 'USD' }] : [ { value: 'OCEAN', label: 'OCEAN' }, { value: 'FET', label: 'FET' }, { value: 'AGIX', label: 'AGIX' }, { value: 'CUDOS', label: 'CUDOS' } ] return (