This commit is contained in:
Kenneth Jannette
2024-01-19 19:08:48 -06:00
parent 36b8a722b3
commit 2fc35a0429
2 changed files with 8 additions and 27 deletions

View File

@@ -62,7 +62,8 @@ const SignupPage = () => {
};
const validatePaymentData = () => {
const newPaymentData = getValidatedFormData(data, paymentfields);
console.log("paymentData", paymentData);
const newPaymentData = getValidatedFormData(paymentData, paymentfields);
const hasErrors = isFormDataHasErrors(newPaymentData);
setPaymentData(newPaymentData);
return hasErrors ? null : objectMap(({ value }) => value, newPaymentData);
@@ -122,6 +123,7 @@ const SignupPage = () => {
return;
}
*/
setShowPaymentModal(true);
};
@@ -131,35 +133,13 @@ const SignupPage = () => {
// handle failure
}
const handleSignUp = async (e) => {
const handleSignup = async (e) => {
e.preventDefault();
const paymentDataValues = validatePaymentData();
if (paymentDataValues === null) {
return;
}
const dataValues = validateData();
if (dataValues === null) {
return;
}
setIsBusy(true);
const paymentSuccess = "true"; // 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."
);
}
}
console.log("paymentDataValues", paymentDataValues);
};
return (
@@ -264,7 +244,7 @@ const SignupPage = () => {
paymentfields={paymentfields}
setShowPaymentModal={setShowPaymentModal}
handleChangePaymentInput={handleChangePaymentInput}
handleSignUp={handleSignUp}
handleSignup={handleSignup}
modalText={modalText}
/>
) : (