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