@@ -15,12 +15,16 @@ import ArrowLeftIcon from "../public/ui/arrow-left.svg?inline"
1515import { Button } from "./Button"
1616
1717interface DonateCheckoutProps {
18- onComplete : ( ) => void
19- className ?: string
2018 backUrl ?: string
19+ className ?: string
20+ onComplete : ( ) => void
2121}
2222
23- export function DonateCheckout ( { className, backUrl } : DonateCheckoutProps ) {
23+ export function DonateCheckout ( {
24+ className,
25+ backUrl,
26+ onComplete,
27+ } : DonateCheckoutProps ) {
2428 const checkout = useCheckout ( )
2529
2630 const [ email , setEmail ] = useState ( "" )
@@ -58,19 +62,17 @@ export function DonateCheckout({ className, backUrl }: DonateCheckoutProps) {
5862 return
5963 }
6064
61- const confirmResult = await checkout . confirm ( )
65+ const confirmResult = await checkout . confirm ( {
66+ redirect : "if_required" , // Only redirect if required
67+ } )
6268
63- // This point will only be reached if there is an immediate error when
64- // confirming the payment. Otherwise, your customer will be redirected to
65- // your `return_url`. For some payment methods like iDEAL, your customer will
66- // be redirected to an intermediate site first to authorize the payment, then
67- // redirected to the `return_url`.
6869 if ( confirmResult . type === "error" ) {
6970 setMessage ( confirmResult . error . message )
7071 setIsLoading ( false )
7172 }
73+ onComplete ( )
7274 } ,
73- [ checkout , email ]
75+ [ checkout , email , onComplete ]
7476 )
7577
7678 return (
@@ -128,14 +130,14 @@ export function DonateCheckout({ className, backUrl }: DonateCheckoutProps) {
128130 onChange = { handleChange }
129131130132 className = { classNames (
131- "w-full p-4 bg-gray-2 rounded-md placeholder:text-gray-1"
133+ "w-full p-4 rounded-md transition-colors" ,
134+ "border-2 border-gray-2 hocus:border-gray-1 dark:border-gray-1" ,
135+ "disabled:border-gray-2 disabled:hocus:border-gray-2"
132136 ) }
133137 onBlur = { handleEmailBlur }
138+ disabled = { isLoading }
134139 />
135140 </ label >
136- { /* <hr className="my-4 border-t border-gray-3" />
137- <h4 className="mb-2 mt-4">Billing Address</h4>
138- <AddressElement options={{ mode: "billing" }} /> */ }
139141 </ div >
140142
141143 < div className = "w-full" >
0 commit comments