@@ -23,10 +23,14 @@ const PaymentModal = ({
|
||||
const ModalForm = () => {
|
||||
return splitEvery(Object.keys(paymentfields), fieldsChunkSize).map(
|
||||
(names, j) => (
|
||||
<Row key={`row${j}`}>
|
||||
<Row key={`row${j}-modal`}>
|
||||
{names.map((name, i) => (
|
||||
<Col key={`${name}${i + fieldsChunkSize * j}`} className="mb-3">
|
||||
<Col
|
||||
key={`${name}${i + fieldsChunkSize * j}-modal`}
|
||||
className="mb-3"
|
||||
>
|
||||
<TextInput
|
||||
key={`${name}-modal-input`}
|
||||
name={name}
|
||||
value={paymentData[name].value}
|
||||
onChange={(e) => handleChangePaymentInput(e, name)}
|
||||
|
||||
@@ -42,7 +42,6 @@ const SignupPage = () => {
|
||||
};
|
||||
|
||||
const handleChangePaymentInput = (e, name) => {
|
||||
console.log("e, name", e, name);
|
||||
const newPaymentData = handleFormDataChange(
|
||||
e,
|
||||
name,
|
||||
@@ -62,7 +61,6 @@ const SignupPage = () => {
|
||||
};
|
||||
|
||||
const validatePaymentData = () => {
|
||||
console.log("paymentData", paymentData);
|
||||
const newPaymentData = getValidatedFormData(paymentData, paymentfields);
|
||||
const hasErrors = isFormDataHasErrors(newPaymentData);
|
||||
setPaymentData(newPaymentData);
|
||||
@@ -114,7 +112,7 @@ const SignupPage = () => {
|
||||
|
||||
const handleProceedToPayment = (e) => {
|
||||
e.preventDefault();
|
||||
/*
|
||||
|
||||
if (isBusy) {
|
||||
return;
|
||||
}
|
||||
@@ -122,7 +120,6 @@ const SignupPage = () => {
|
||||
if (dataValues === null) {
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
setShowPaymentModal(true);
|
||||
};
|
||||
@@ -139,7 +136,31 @@ 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."
|
||||
);
|
||||
}
|
||||
} else {
|
||||
//handle payment failure
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -240,6 +261,7 @@ const SignupPage = () => {
|
||||
</div>
|
||||
{showPaymentModal ? (
|
||||
<PaymentModal
|
||||
key="modal-one-xc"
|
||||
paymentData={paymentData}
|
||||
paymentfields={paymentfields}
|
||||
setShowPaymentModal={setShowPaymentModal}
|
||||
|
||||
@@ -8,7 +8,6 @@ export const paymentfields = {
|
||||
cardLastName: {
|
||||
required: true,
|
||||
label: "Card Last Name",
|
||||
maxLength: 45,
|
||||
type: "cardLastName",
|
||||
},
|
||||
cardNumber: {
|
||||
|
||||
Reference in New Issue
Block a user