Merge pull request #33 from kjannette/stripeInputs2

Stripe inputs2
This commit is contained in:
S Jannette
2024-01-19 18:39:23 -06:00
committed by GitHub
5 changed files with 45 additions and 17 deletions

View File

@@ -31,8 +31,8 @@ const PaymentModal = ({
(names, j) => (
<Row key={`row${j}`}>
{names.map((name, i) => (
<Row key={`${name}${i + fieldsChunkSize * j}`} className="mb-3">
{console.log("paymentdata", paymentData)}
<Col key={`${name}${i + fieldsChunkSize * j}`} className="mb-3">
{console.log("paymentdata, name", paymentData, name)}
<TextInput
name={name}
value={paymentData[name].value}
@@ -48,7 +48,7 @@ const PaymentModal = ({
values={paymentfields[name].values}
disabled={isBusy}
/>
</Row>
</Col>
))}
</Row>
)
@@ -61,7 +61,7 @@ const PaymentModal = ({
<Modal.Title>Enter Payment Card Information</Modal.Title>
</Modal.Header>
<Modal.Body>
<span>{modalText}</span>
<div className="payment-modal-text-wrapper">{modalText}</div>
<Form className="payment-form">
<ModalForm />
</Form>
@@ -77,7 +77,7 @@ const PaymentModal = ({
disabled={isBusy}
className="primary-button"
onClick={handleSignup}
labelText={buttonLabelText}
labelText="Signup"
/>
</Modal.Footer>
</Modal>

View File

@@ -32,6 +32,7 @@ const SignupPage = () => {
getFormDataDefaults(paymentfields)
);
const [showPaymentModal, setShowPaymentModal] = useState(false);
const modalText = "Description of monthly and annual subscriptions";
const handleChangeInput = (e, name) => {
const newData = handleFormDataChange(e, name, data, signupfields);
@@ -41,9 +42,15 @@ const SignupPage = () => {
};
const handleChangePaymentInput = (e, name) => {
const newData = handleFormDataChange(e, name, data, paymentfields);
if (newData !== null) {
setPaymentData(newData);
console.log("e, name", e, name);
const newPaymentData = handleFormDataChange(
e,
name,
paymentData,
paymentfields
);
if (newPaymentData !== null) {
setPaymentData(newPaymentData);
}
};
@@ -106,6 +113,7 @@ const SignupPage = () => {
const handleProceedToPayment = (e) => {
e.preventDefault();
/*
if (isBusy) {
return;
}
@@ -113,13 +121,14 @@ const SignupPage = () => {
if (dataValues === null) {
return;
}
*/
setShowPaymentModal(true);
};
async function handleStripeAuthorization(paymentDataValues) {
//Do calls to Stripe API
// Do: calls to Stripe API
// if success, return some truthy value or
// handleFailure()
// handle failure
}
const handleSignUp = async (e) => {
@@ -167,6 +176,7 @@ const SignupPage = () => {
<Row key={`row${j}`}>
{names.map((name, i) => (
<Col key={`${name}${i + fieldsChunkSize * j}`} className="mb-3">
{console.log("data, name", data, name)}
<TextInput
name={name}
value={data[name].value}
@@ -225,7 +235,7 @@ const SignupPage = () => {
</Form>
<div className="signup-button-box">
<Button
className="primary-button"
className="primary-button signup-proceed"
type="button"
size="lg"
onClick={handleProceedToPayment}
@@ -234,7 +244,7 @@ const SignupPage = () => {
/>
<div className="mt-3">
<span>
<Link to="/">Return to login</Link>
<Link to="/login">Go to login</Link>
</span>
</div>
</div>
@@ -255,6 +265,7 @@ const SignupPage = () => {
setShowPaymentModal={setShowPaymentModal}
handleChangePaymentInput={handleChangePaymentInput}
handleSignUp={handleSignUp}
modalText={modalText}
/>
) : (
<></>

View File

@@ -1,16 +1,27 @@
export const paymentfields = {
cardFirstName: { required: true, label: "Card First Name", maxLength: 45 },
cardLastName: { required: true, label: "Card Last Name", maxLength: 45 },
cardFirstName: {
required: true,
label: "Card First Name",
maxLength: 45,
type: "cardFirstName",
},
cardLastName: {
required: true,
label: "Card Last Name",
maxLength: 45,
type: "cardLastName",
},
cardNumber: {
required: true,
label: "Card Number",
minLength: 16,
maxLength: 16,
type: "cardNumber",
},
cardCvvCode: {
required: true,
label: "Card CVV Number",
maxLength: 5,
type: "cvv",
type: "cardCvvCode",
},
};

View File

@@ -76,3 +76,8 @@
.payment-form {
width: 740px;
}
.payment-modal-text-wrapper {
margin: 8px 0px 18px 0px;
padding-left: 4px;
}

View File

@@ -42,6 +42,7 @@
flex-direction: column;
align-items: flex-end;
}
.signup-btn {
width: 150px;
.signup-proceed {
width: 160px;
}