The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
try to fix hcaptcha in modal
Kevin Grünebergceb5e9b4f803
diff --git a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsxindex 5b23757d3c0..e28d65ec9fd 100644--- a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx+++ b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx@@ -1,4 +1,4 @@-import { FC, useEffect, useRef, useState } from 'react'+import { FC, useCallback, useEffect, useRef, useState } from 'react'import { IconLoader, Modal } from 'ui'import { loadStripe } from '@stripe/stripe-js'import { Elements } from '@stripe/react-stripe-js'@@ -24,32 +24,41 @@ const AddNewPaymentMethodModal: FC<Props> = ({ visible, returnUrl, onCancel }) =const [captchaLoaded, setCaptchaLoaded] = useState(false)const [captchaToken, setCaptchaToken] = useState<string | null>(null)- const captchaRef = useRef<HCaptcha>(null)+ const [captchaRef, setCaptchaRef] = useState<HCaptcha | null>(null)++ const captchaRefCallback = useCallback((node) => {+ setCaptchaRef(node)+ }, [])useEffect(() => {const loadPaymentForm = async () => {- if (visible && captchaLoaded) {+ if (visible && captchaLoaded && captchaRef) {+ console.log('load payment form', { visible, captchaLoaded })let token = captchaTokenif (!token) {- const captchaResponse = await captchaRef.current?.execute({ async: true })+ const captchaResponse = await captchaRef.execute({ async: true })token = captchaResponse?.response ?? null}+ console.log('Setting up intent', { token })+await setupIntent(token ?? undefined)resetCaptcha()}}loadPaymentForm()- }, [visible, captchaLoaded])+ }, [visible, captchaLoaded, captchaRef])const onCaptchaLoaded = () => {+ console.log('on captcha loaded')setCaptchaLoaded(true)}const resetCaptcha = () => {+ console.log('Resetting captcha')setCaptchaToken(null)- captchaRef.current?.resetCaptcha()+ captchaRef?.resetCaptcha()}const setupIntent = async (hcaptchaToken: string | undefined) => {@@ -77,9 +86,16 @@ const AddNewPaymentMethodModal: FC<Props> = ({ visible, returnUrl, onCancel }) =} as anyreturn (- <>+ <Modal+ hideFooter+ size="medium"+ visible={visible}+ header="Add new payment method"+ onCancel={onCancel}+ className="PAYMENT"+ ><HCaptcha- ref={captchaRef}+ ref={captchaRefCallback}sitekey={process.env.NEXT_PUBLIC_HCAPTCHA_SITE_KEY!}size="invisible"onLoad={onCaptchaLoaded}@@ -91,27 +107,18 @@ const AddNewPaymentMethodModal: FC<Props> = ({ visible, returnUrl, onCancel }) =setCaptchaToken(null)}}/>- <Modal- hideFooter- size="medium"- visible={visible}- header="Add new payment method"- onCancel={onCancel}- className="PAYMENT"- >- <div className="space-y-4 py-4">- {intent !== undefined ? (- <Elements stripe={stripePromise} options={options}>- <AddPaymentMethodForm returnUrl={returnUrl} onCancel={onCancel} />- </Elements>- ) : (- <div className="flex w-full items-center justify-center py-20">- <IconLoader size={16} className="animate-spin" />- </div>- )}- </div>- </Modal>- </>+ <div className="space-y-4 py-4">+ {intent !== undefined ? (+ <Elements stripe={stripePromise} options={options}>+ <AddPaymentMethodForm returnUrl={returnUrl} onCancel={onCancel} />+ </Elements>+ ) : (+ <div className="flex w-full items-center justify-center py-20">+ <IconLoader size={16} className="animate-spin" />+ </div>+ )}+ </div>+ </Modal>)}