Change loading logic for when hcaptcha is involved in payment summary panel enterprise

This commit is contained in:
Joshen Lim committed 2022-12-21 14:05:23 +07:00
1 parent 773403b4ab
commit ebed18fcfe
2 files changed
+7 -6

No files matched your search

@@ -139,10 +139,14 @@ const EnterpriseUpdate: FC<Props> = ({
// Last todo to support enterprise billing on dashboard + E2E test
const onConfirmPayment = async () => {
let token = captchaToken
setIsSubmitting(true)
const token =
captchaToken ?? (await captchaRef.current?.execute({ async: true }))?.response ?? undefined
if (!token) {
const captchaResponse = await captchaRef.current?.execute({ async: true })
token = captchaResponse?.response ?? null
setIsSubmitting(false)
return
}
const payload = {
@@ -157,8 +161,6 @@ const EnterpriseUpdate: FC<Props> = ({
),
tier: currentSubscription.tier.price_id,
}
setIsSubmitting(true)
const res = await patch(`${API_URL}/projects/${projectRef}/subscription`, payload)
resetCaptcha()
@@ -179,7 +179,6 @@ const ProUpgrade: FC<Props> = ({
token ?? undefined
)
const res = await patch(`${API_URL}/projects/${projectRef}/subscription`, payload)
resetCaptcha()
if (res?.error) {