more
This commit is contained in:
@@ -15,15 +15,13 @@ import {
|
|||||||
import "../../styles/modals.scss";
|
import "../../styles/modals.scss";
|
||||||
|
|
||||||
const PaymentModal = ({
|
const PaymentModal = ({
|
||||||
onCancel,
|
|
||||||
buttonLabelText,
|
buttonLabelText,
|
||||||
modalText,
|
|
||||||
isBusy,
|
isBusy,
|
||||||
handleChangePaymentInput,
|
paymentData,
|
||||||
handleSignup,
|
|
||||||
paymentfields,
|
paymentfields,
|
||||||
paymentdata,
|
handleChangePaymentInput,
|
||||||
setPaymentdata,
|
modalText,
|
||||||
|
handleSignup,
|
||||||
}) => {
|
}) => {
|
||||||
const fieldsChunkSize = 2;
|
const fieldsChunkSize = 2;
|
||||||
|
|
||||||
@@ -33,15 +31,15 @@ const PaymentModal = ({
|
|||||||
<Row key={`row${j}`}>
|
<Row key={`row${j}`}>
|
||||||
{names.map((name, i) => (
|
{names.map((name, i) => (
|
||||||
<Row key={`${name}${i + fieldsChunkSize * j}`} className="mb-3">
|
<Row key={`${name}${i + fieldsChunkSize * j}`} className="mb-3">
|
||||||
{console.log("paymentdata", paymentdata)}
|
{console.log("paymentdata", paymentData)}
|
||||||
<TextInput
|
<TextInput
|
||||||
name={name}
|
name={name}
|
||||||
value={paymentdata[name].value}
|
value={paymentData[name].value}
|
||||||
onChange={(e) => handleChangePaymentInput(e, name)}
|
onChange={(e) => handleChangePaymentInput(e, name)}
|
||||||
error={paymentdata[name].error}
|
error={paymentData[name].error}
|
||||||
message={paymentdata[name].message}
|
message={paymentData[name].message}
|
||||||
label={
|
label={
|
||||||
paymentdata[name].value.length === 0
|
paymentData[name].value.length === 0
|
||||||
? paymentfields[name].label
|
? paymentfields[name].label
|
||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
@@ -57,7 +55,7 @@ const PaymentModal = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal show="true" onHide={onCancel} size="lg">
|
<Modal show="true" size="lg">
|
||||||
<Modal.Header closeButton>
|
<Modal.Header closeButton>
|
||||||
<Modal.Title>Enter Payment Card Information</Modal.Title>
|
<Modal.Title>Enter Payment Card Information</Modal.Title>
|
||||||
</Modal.Header>
|
</Modal.Header>
|
||||||
@@ -71,7 +69,7 @@ const PaymentModal = ({
|
|||||||
<Button
|
<Button
|
||||||
disabled={isBusy}
|
disabled={isBusy}
|
||||||
className="secondary-button"
|
className="secondary-button"
|
||||||
onClick={onCancel}
|
onClick={"onCancel"}
|
||||||
labelText="Cancel"
|
labelText="Cancel"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
@@ -86,3 +84,7 @@ const PaymentModal = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default PaymentModal;
|
export default PaymentModal;
|
||||||
|
|
||||||
|
/*
|
||||||
|
onHide={onCancel}
|
||||||
|
*/
|
||||||
|
|||||||
@@ -25,11 +25,13 @@ import "../../styles/signup.scss";
|
|||||||
const SignupPage = () => {
|
const SignupPage = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [notice, setNotice] = useState("");
|
const [notice, setNotice] = useState("");
|
||||||
|
|
||||||
const fieldsChunkSize = 2;
|
const fieldsChunkSize = 2;
|
||||||
|
|
||||||
const [isBusy, setIsBusy] = useState(false);
|
const [isBusy, setIsBusy] = useState(false);
|
||||||
const [data, setData] = useState(getFormDataDefaults(signupfields));
|
const [data, setData] = useState(getFormDataDefaults(signupfields));
|
||||||
|
const [paymentData, setPaymentData] = useState(
|
||||||
|
getFormDataDefaults(paymentfields)
|
||||||
|
);
|
||||||
|
const [showPaymentModal, setShowPaymentModal] = useState(false);
|
||||||
|
|
||||||
const handleChangeInput = (e, name) => {
|
const handleChangeInput = (e, name) => {
|
||||||
const newData = handleFormDataChange(e, name, data, signupfields);
|
const newData = handleFormDataChange(e, name, data, signupfields);
|
||||||
@@ -38,6 +40,13 @@ const SignupPage = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleChangePaymentInput = (e, name) => {
|
||||||
|
const newData = handleFormDataChange(e, name, data, paymentfields);
|
||||||
|
if (newData !== null) {
|
||||||
|
setPaymentData(newData);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const validateData = () => {
|
const validateData = () => {
|
||||||
const newData = getValidatedFormData(data, signupfields);
|
const newData = getValidatedFormData(data, signupfields);
|
||||||
const hasErrors = isFormDataHasErrors(newData);
|
const hasErrors = isFormDataHasErrors(newData);
|
||||||
@@ -97,11 +106,14 @@ const SignupPage = () => {
|
|||||||
if (dataValues === null) {
|
if (dataValues === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
showPaymentModal(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSignup = async (e) => {
|
const handleSignUp = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const dataValues = validateData();
|
const dataValues = validateData();
|
||||||
|
|
||||||
|
//const paymentSuccess = handleStripeAuthorization(paymentData)
|
||||||
setIsBusy(true);
|
setIsBusy(true);
|
||||||
try {
|
try {
|
||||||
const userCredential = await createUserWithEmailAndPassword(
|
const userCredential = await createUserWithEmailAndPassword(
|
||||||
@@ -195,9 +207,9 @@ const SignupPage = () => {
|
|||||||
className="primary-button"
|
className="primary-button"
|
||||||
type="button"
|
type="button"
|
||||||
size="lg"
|
size="lg"
|
||||||
onClick={handleSignup}
|
onClick={handleProceedToPayment}
|
||||||
disabled={isBusy}
|
disabled={isBusy}
|
||||||
labelText="Create Account"
|
labelText="Proceed to Payment"
|
||||||
/>
|
/>
|
||||||
<div className="mt-3">
|
<div className="mt-3">
|
||||||
<span>
|
<span>
|
||||||
@@ -215,6 +227,17 @@ const SignupPage = () => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{showPaymentModal ? (
|
||||||
|
<PaymentModal
|
||||||
|
paymentData={paymentData}
|
||||||
|
paymentfields={paymentfields}
|
||||||
|
setShowPaymentModal={setShowPaymentModal}
|
||||||
|
handleChangePaymentInput={handleChangePaymentInput}
|
||||||
|
handleSignUp={handleSignUp}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user