@@ -168,8 +168,13 @@ export const PaymentForm = ({
168168
169169 const isActivePeanutWallet = useMemo ( ( ) => ! ! user && isPeanutWalletConnected , [ user , isPeanutWalletConnected ] )
170170
171+ const isRequestPotLink = ! ! chargeDetails ?. requestLink
172+
171173 useEffect ( ( ) => {
172- if ( initialSetupDone || showRequestPotInitialView ) return
174+ // skip this step for request pot payments
175+ // Amount is set by the user so we dont need to manually update it
176+ // chain and token are also USDC arb always, for cross-chain we use Daimo
177+ if ( initialSetupDone || showRequestPotInitialView || isRequestPotLink ) return
173178
174179 if ( amount ) {
175180 setInputTokenAmount ( amount )
@@ -192,7 +197,7 @@ export const PaymentForm = ({
192197 }
193198
194199 setInitialSetupDone ( true )
195- } , [ chain , token , amount , initialSetupDone , requestDetails , showRequestPotInitialView ] )
200+ } , [ chain , token , amount , initialSetupDone , requestDetails , showRequestPotInitialView , isRequestPotLink ] )
196201
197202 // reset error when component mounts or recipient changes
198203 useEffect ( ( ) => {
@@ -301,17 +306,27 @@ export const PaymentForm = ({
301306
302307 // Calculate USD value when requested token price is available
303308 useEffect ( ( ) => {
304- if ( showRequestPotInitialView || ! requestedTokenPriceData ?. price || ! requestDetails ?. tokenAmount ) return
309+ // skip this step for request pot payments
310+ // Amount is set by the user so we dont need to manually update it
311+ // No usd conversion needed because amount will always be USDC
312+ if (
313+ showRequestPotInitialView ||
314+ ! requestedTokenPriceData ?. price ||
315+ ! requestDetails ?. tokenAmount ||
316+ isRequestPotLink
317+ )
318+ return
305319
306320 const tokenAmount = parseFloat ( requestDetails . tokenAmount )
307321 if ( isNaN ( tokenAmount ) || tokenAmount <= 0 ) return
308322
309323 if ( isNaN ( requestedTokenPriceData . price ) || requestedTokenPriceData . price === 0 ) return
310324
311325 const usdValue = formatAmount ( tokenAmount * requestedTokenPriceData . price )
326+
312327 setInputTokenAmount ( usdValue )
313328 setUsdValue ( usdValue )
314- } , [ requestedTokenPriceData ?. price , requestDetails ?. tokenAmount , showRequestPotInitialView ] )
329+ } , [ requestedTokenPriceData ?. price , requestDetails ?. tokenAmount , showRequestPotInitialView , isRequestPotLink ] )
315330
316331 const canInitiatePayment = useMemo < boolean > ( ( ) => {
317332 let amountIsSet = false
@@ -581,10 +596,12 @@ export const PaymentForm = ({
581596
582597 // Initialize inputTokenAmount
583598 useEffect ( ( ) => {
584- if ( amount && ! inputTokenAmount && ! initialSetupDone ) {
599+ // skip this step for request pot payments
600+ // Amount is set by the user so we dont need to manually update it
601+ if ( amount && ! inputTokenAmount && ! initialSetupDone && ! showRequestPotInitialView ) {
585602 setInputTokenAmount ( amount )
586603 }
587- } , [ amount , inputTokenAmount , initialSetupDone ] )
604+ } , [ amount , inputTokenAmount , initialSetupDone , showRequestPotInitialView ] )
588605
589606 useEffect ( ( ) => {
590607 const stepFromURL = searchParams . get ( 'step' )
@@ -620,6 +637,7 @@ export const PaymentForm = ({
620637
621638 // ensure inputTokenAmount is a valid positive number before allowing payment
622639 const numericAmount = parseFloat ( inputTokenAmount )
640+
623641 if ( isNaN ( numericAmount ) || numericAmount <= 0 ) {
624642 if ( ! isExternalWalletFlow ) return true
625643 }
@@ -691,24 +709,8 @@ export const PaymentForm = ({
691709
692710 if ( contributionAmounts . length === 0 ) return { percentage : 0 , suggestedAmount : 0 }
693711
694- const avgContribution = contributionAmounts . reduce ( ( sum , amt ) => sum + amt , 0 ) / contributionAmounts . length
695-
696- // Calculate remaining amount (could be negative if over-contributed)
697- const remaining = totalAmount - totalCollected
698- let suggestedAmount : number
699-
700- // If pot is already full or over-filled, suggest minimum contribution
701- if ( remaining <= 0 ) {
702- // Pot is full/overfilled - suggest the smallest previous contribution or 10% of pot
703- const minContribution = Math . min ( ...contributionAmounts )
704- suggestedAmount = Math . min ( minContribution , totalAmount * 0.1 )
705- } else if ( remaining < avgContribution ) {
706- // If remaining is less than average, suggest the remaining amount
707- suggestedAmount = remaining
708- } else {
709- // Otherwise, suggest the average contribution (most common pattern)
710- suggestedAmount = avgContribution
711- }
712+ // suggest the average contribution (most common pattern)
713+ const suggestedAmount = contributionAmounts . reduce ( ( sum , amt ) => sum + amt , 0 ) / contributionAmounts . length
712714
713715 // Convert amount to percentage of total pot
714716 const percentage = ( suggestedAmount / totalAmount ) * 100
0 commit comments