diff --git a/components/Bounty/BountyForm.tsx b/components/Bounty/BountyForm.tsx index dd5fa157..1171d11e 100644 --- a/components/Bounty/BountyForm.tsx +++ b/components/Bounty/BountyForm.tsx @@ -56,79 +56,7 @@ interface BountyFormProps { className?: string; } -// Reuse the existing components from CreateBountyModal -const CurrencyInput = ({ - value, - onChange, - currency, - onCurrencyToggle, - convertedAmount, - suggestedAmount, - error, - isExchangeRateLoading, -}: { - value: string; - onChange: (e: React.ChangeEvent) => void; - currency: Currency; - onCurrencyToggle: () => void; - convertedAmount?: string; - suggestedAmount?: string; - error?: string; - isExchangeRateLoading?: boolean; -}) => { - const currentAmount = parseFloat(value.replace(/,/g, '')) || 0; - const suggestedAmountValue = suggestedAmount - ? parseFloat(suggestedAmount.replace(/[^0-9.]/g, '')) - : 0; - - const isBelowSuggested = currentAmount < suggestedAmountValue; - const suggestedTextColor = !currentAmount - ? 'text-gray-500' - : isBelowSuggested - ? 'text-orange-500' - : 'text-green-500'; - - return ( -
- - {currency} - - - } - /> - {error &&

{error}

} - {suggestedAmount && !error && ( -

- Suggested amount for peer review: {suggestedAmount} - {currency === 'RSC' && - !isExchangeRateLoading && - !suggestedAmount.includes('Loading') && - ' (150 USD)'} -

- )} - {isExchangeRateLoading ? ( -
Loading exchange rate...
- ) : ( - convertedAmount &&
{convertedAmount}
- )} -
- ); -}; +import { CurrencyInput } from '@/components/ui/form/CurrencyInput'; const BountyLengthSelector = ({ selected, @@ -375,6 +303,14 @@ export function BountyForm({ workId, onSubmitSuccess, className }: BountyFormPro const handleAmountChange = (e: React.ChangeEvent) => { const rawValue = e.target.value.replace(/[^0-9.]/g, ''); + + // Allow empty string to reset the input + if (rawValue === '') { + setInputAmount(0); + setAmountError(undefined); + return; + } + const numValue = parseFloat(rawValue); if (!hasInteractedWithAmount) { @@ -396,15 +332,14 @@ export function BountyForm({ workId, onSubmitSuccess, className }: BountyFormPro } else { setAmountError(undefined); } - } else { - setInputAmount(0); - setAmountError('Please enter a valid amount'); } }; const getFormattedInputValue = () => { + // If user has interacted and value is 0, show empty string to allow clearing + if (hasInteractedWithAmount && inputAmount === 0) return ''; if (inputAmount === 0) return ''; - return inputAmount.toLocaleString(); + return inputAmount; }; const toggleCurrency = () => {