diff --git a/src/Components/SignupPage/SignupPage.js b/src/Components/SignupPage/SignupPage.js index 1292f3e..f0ab01f 100644 --- a/src/Components/SignupPage/SignupPage.js +++ b/src/Components/SignupPage/SignupPage.js @@ -112,7 +112,7 @@ const SignupPage = () => { const handleProceedToPayment = (e) => { e.preventDefault(); - /* + if (isBusy) { return; } @@ -120,7 +120,6 @@ const SignupPage = () => { if (dataValues === null) { return; } - */ setShowPaymentModal(true); }; @@ -137,7 +136,29 @@ const SignupPage = () => { if (paymentDataValues === null) { return; } - console.log("paymentDataValues", paymentDataValues); + const dataValues = validateData(); + if (dataValues === null) { + return; + } + setIsBusy(true); + const paymentSuccess = handleStripeAuthorization(paymentDataValues); + if (paymentSuccess) { + try { + const userCredential = await createUserWithEmailAndPassword( + auth, + dataValues.email, + dataValues.password + ); + const user = userCredential.user; + await saveUserData(user.uid, dataValues); + navigate("/"); + } catch (error) { + setIsBusy(false); + setNotice( + error.message || "Sorry, something went wrong. Please try again." + ); + } + } }; return (