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