From c29d0586e597f06d30130d873585b80639f2a8d3 Mon Sep 17 00:00:00 2001 From: PoornaChandra2005 Date: Wed, 11 Feb 2026 07:29:51 +0530 Subject: [PATCH 1/2] fix: allow clearing bounty amount input --- components/Bounty/BountyForm.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/components/Bounty/BountyForm.tsx b/components/Bounty/BountyForm.tsx index dd5fa157..abedbbce 100644 --- a/components/Bounty/BountyForm.tsx +++ b/components/Bounty/BountyForm.tsx @@ -375,6 +375,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,13 +404,12 @@ 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(); }; From 3085651ae6404b550280c78cf64e93da1b7cf5c3 Mon Sep 17 00:00:00 2001 From: PoornaChandra2005 Date: Wed, 11 Feb 2026 07:31:54 +0530 Subject: [PATCH 2/2] refactor: use shared CurrencyInput component to reduce duplication --- components/Bounty/BountyForm.tsx | 76 +------------------------------- 1 file changed, 2 insertions(+), 74 deletions(-) diff --git a/components/Bounty/BountyForm.tsx b/components/Bounty/BountyForm.tsx index abedbbce..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, @@ -411,7 +339,7 @@ export function BountyForm({ workId, onSubmitSuccess, className }: BountyFormPro // 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 = () => {