This commit is contained in:
Kenneth Jannette
2024-01-19 15:43:03 -06:00
parent 21cf110cf2
commit 1c67511871

View File

@@ -58,6 +58,13 @@ const SignupPage = () => {
return hasErrors ? null : objectMap(({ value }) => value, newData); return hasErrors ? null : objectMap(({ value }) => value, newData);
}; };
const validatePaymentData = () => {
const newData = getValidatedFormData(data, signupfields);
const hasErrors = isFormDataHasErrors(newData);
setPaymentdata(newData);
return hasErrors ? null : objectMap(({ value }) => value, newData);
};
const [cardNumber, setCardNumber] = useState(""); const [cardNumber, setCardNumber] = useState("");
const [cardName, setCardName] = useState(""); const [cardName, setCardName] = useState("");
const [cardSecNumber, setCardSecNumber] = useState(""); const [cardSecNumber, setCardSecNumber] = useState("");
@@ -105,40 +112,49 @@ const SignupPage = () => {
} }
} }
async function handleStripePaymentAuthorization(paymentDataValues) {
console.log(paymentDataValues);
}
const handleSignup = async (e) => { const handleSignup = async (e) => {
console.log("handleSignup");
/*
e.preventDefault(); e.preventDefault();
if (isBusy) { const paymentDataValues = validatePaymentData();
if (paymentDataValues === null) {
return; return;
} }
/*
const paymentSuccess = handleStripePaymentAuthorization(paymentDataValues);
setIsBusy(true); if (paymentSuccess) {
try { if (isBusy) {
const userCredential = await createUserWithEmailAndPassword( return;
auth, }
dataValues.email,
dataValues.password setIsBusy(true);
); try {
const user = userCredential.user; const userCredential = await createUserWithEmailAndPassword(
await saveUserData(user.uid, dataValues); auth,
navigate("/"); dataValues.email,
} catch (error) { dataValues.password
setIsBusy(false); );
setNotice( const user = userCredential.user;
error.message || "Sorry, something went wrong. Please try again." await saveUserData(user.uid, dataValues);
); navigate("/");
} catch (error) {
setIsBusy(false);
setNotice(
error.message || "Sorry, something went wrong. Please try again."
);
}
} }
*/ */
}; };
const handleProceed = () => { const handleProceed = () => {
/*
const dataValues = validateData(); const dataValues = validateData();
if (dataValues === null) { if (dataValues === null) {
return; return;
} }
*/
setShowPaymentModal(true); setShowPaymentModal(true);
}; };