@@ -1,3 +1,4 @@
|
|||||||
|
import { useMemo } from "react";
|
||||||
import Button from "../../pageElements/Button";
|
import Button from "../../pageElements/Button";
|
||||||
import Modal from "react-bootstrap/Modal";
|
import Modal from "react-bootstrap/Modal";
|
||||||
import TextInput from "../../pageElements/TextInput";
|
import TextInput from "../../pageElements/TextInput";
|
||||||
@@ -8,12 +9,10 @@ import Row from "react-bootstrap/Row";
|
|||||||
import "../../styles/modals.scss";
|
import "../../styles/modals.scss";
|
||||||
|
|
||||||
const PaymentModal = ({
|
const PaymentModal = ({
|
||||||
buttonLabelText,
|
|
||||||
isBusy,
|
isBusy,
|
||||||
paymentData,
|
paymentData,
|
||||||
paymentfields,
|
paymentfields,
|
||||||
handleChangePaymentInput,
|
handleChangePaymentInput,
|
||||||
orderSummary,
|
|
||||||
handleSignUp,
|
handleSignUp,
|
||||||
setShowPaymentModal,
|
setShowPaymentModal,
|
||||||
handleSignup,
|
handleSignup,
|
||||||
@@ -23,18 +22,39 @@ const PaymentModal = ({
|
|||||||
numberOfAccountsToAdd,
|
numberOfAccountsToAdd,
|
||||||
}) => {
|
}) => {
|
||||||
const monthlyAddAccountPrice = selectedPlan[0].pricing[2].amount;
|
const monthlyAddAccountPrice = selectedPlan[0].pricing[2].amount;
|
||||||
const annualAddAccountPrice = monthlyAddAccountPrice * 12;
|
|
||||||
|
const monthlySubscriptionPriceToday = selectedPlan[0].pricing[0].amount;
|
||||||
|
const annualSubscriptionPriceToday = selectedPlan[0].pricing[1].amount * 12;
|
||||||
|
|
||||||
|
const additionalAccountsMonthlyPriceToday =
|
||||||
|
selectedPlan[0].pricing[2].amount * numberOfAccountsToAdd;
|
||||||
|
|
||||||
|
const additionalAccountsAnnualPriceToday =
|
||||||
|
additionalAccountsMonthlyPriceToday * 12;
|
||||||
|
|
||||||
|
const tempExtraAccountsPrice = isAnnual
|
||||||
|
? additionalAccountsAnnualPriceToday
|
||||||
|
: additionalAccountsMonthlyPriceToday;
|
||||||
|
const extraAccountsPrice =
|
||||||
|
tempExtraAccountsPrice === NaN || tempExtraAccountsPrice === undefined
|
||||||
|
? 0
|
||||||
|
: 0;
|
||||||
const showAdditionaLAccountsView =
|
const showAdditionaLAccountsView =
|
||||||
(selectedPlan[0]?.value === "partner" && numberOfAccountsToAdd > 0) ||
|
(selectedPlan[0]?.value === "partner" && numberOfAccountsToAdd > 0) ||
|
||||||
(selectedPlan[0]?.value === "seniorPartner" && numberOfAccountsToAdd > 0);
|
(selectedPlan[0]?.value === "seniorPartner" && numberOfAccountsToAdd > 0);
|
||||||
|
|
||||||
const planName = selectedPlan[0].name ? selectedPlan[0].name : null;
|
const planName = selectedPlan[0].name ? selectedPlan[0].name : null;
|
||||||
const billingPeriod = isAnnual ? "Annually" : "Monthly";
|
const billingPeriod = isAnnual ? "Annually" : "Monthly";
|
||||||
const amountToday = isAnnual
|
const amountToday = isAnnual
|
||||||
? selectedPlan[0]?.pricing[0]?.amount
|
? annualSubscriptionPriceToday
|
||||||
: selectedPlan[0]?.pricing[1]?.amount;
|
: monthlySubscriptionPriceToday;
|
||||||
console.log("annualAddAccountPrice", annualAddAccountPrice);
|
const totalToday = amountToday + extraAccountsPrice;
|
||||||
console.log("isAnnual", isAnnual);
|
console.log("amoutnToday", amountToday);
|
||||||
console.log("numberOfAccountsToAdd", numberOfAccountsToAdd);
|
console.log("extraAccountsPrice", extraAccountsPrice);
|
||||||
|
|
||||||
|
function handleValidateAndPay() {
|
||||||
|
handleSignup(totalToday);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Modal show="true" size="lg">
|
<Modal show="true" size="lg">
|
||||||
<Modal.Header className="payment-modal-header" closeButton>
|
<Modal.Header className="payment-modal-header" closeButton>
|
||||||
@@ -48,7 +68,6 @@ const PaymentModal = ({
|
|||||||
<div className="paymodal-summary-right">Subscription Type:</div>
|
<div className="paymodal-summary-right">Subscription Type:</div>
|
||||||
<div className="paymodal-summary-left">{planName}</div>
|
<div className="paymodal-summary-left">{planName}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="payment-modal-text-wrapper">
|
<div className="payment-modal-text-wrapper">
|
||||||
<div className="paymodal-summary-right">
|
<div className="paymodal-summary-right">
|
||||||
Billing Period/Amount:
|
Billing Period/Amount:
|
||||||
@@ -57,25 +76,29 @@ const PaymentModal = ({
|
|||||||
{billingPeriod} - ${amountToday}
|
{billingPeriod} - ${amountToday}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{showAdditionaLAccountsView ? (
|
{numberOfAccountsToAdd !== undefined &&
|
||||||
|
numberOfAccountsToAdd > 0 ? (
|
||||||
<div className="payment-modal-text-wrapper">
|
<div className="payment-modal-text-wrapper">
|
||||||
<div className="paymodal-summary-right">
|
<div className="paymodal-summary-right">
|
||||||
Additional Accounts:
|
{numberOfAccountsToAdd} Addiitonal{" "}
|
||||||
|
{numberOfAccountsToAdd > 1 ? `accounts` : `account`}
|
||||||
</div>
|
</div>
|
||||||
<div className="paymodal-summary-left">
|
<div className="paymodal-summary-left">
|
||||||
{isAnnual ? (
|
{billingPeriod} - ${extraAccountsPrice}
|
||||||
<p>
|
</div>
|
||||||
{" "}
|
</div>
|
||||||
{numberOfAccountsToAdd}/ x 12 months = $
|
) : (
|
||||||
{annualAddAccountPrice}
|
<></>
|
||||||
</p>
|
)}
|
||||||
) : (
|
<div className="payment-modal-text-wrapper">
|
||||||
<p>
|
<div className="paymodal-summary-right">Total today:</div>
|
||||||
{" "}
|
<div className="paymodal-summary-left">${totalToday}</div>
|
||||||
{numberOfAccountsToAdd}/per month = $
|
</div>
|
||||||
{monthlyAddAccountPrice}
|
{isAnnual ? (
|
||||||
</p>
|
<div className="payment-modal-text-wrapper">
|
||||||
)}
|
<div className="paymodal-summary-right"></div>
|
||||||
|
<div className="paymodal-summary-left-bonus">
|
||||||
|
Includes 10% discount for convenient annual billing
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@@ -126,7 +149,7 @@ const PaymentModal = ({
|
|||||||
<Button
|
<Button
|
||||||
disabled={isBusy}
|
disabled={isBusy}
|
||||||
className="primary-button"
|
className="primary-button"
|
||||||
onClick={handleSignup}
|
onClick={handleValidateAndPay}
|
||||||
labelText="Signup"
|
labelText="Signup"
|
||||||
/>
|
/>
|
||||||
</Modal.Footer>
|
</Modal.Footer>
|
||||||
@@ -135,3 +158,23 @@ const PaymentModal = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default PaymentModal;
|
export default PaymentModal;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
{showAdditionaLAccountsView ? (
|
||||||
|
<div className="payment-modal-text-wrapper">
|
||||||
|
<div className="paymodal-summary-right">
|
||||||
|
Additional Accounts:
|
||||||
|
</div>
|
||||||
|
<div className="paymodal-summary-left">
|
||||||
|
{isAnnual
|
||||||
|
? additionalAccountsAnnualPriceToday
|
||||||
|
: additionalAccountsMonthlyPriceToday}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|||||||
@@ -58,11 +58,12 @@ const SignupPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleChangeAccountSelect = (e, name) => {
|
const handleChangeAccountSelect = (e, name) => {
|
||||||
console.log("e, name", e, name);
|
console.log("~~~~~~~~~~~~~~e.target.value, name", e.target.value, name);
|
||||||
const num = e.target.value;
|
const num = e.target.value;
|
||||||
setNumberOfAccountsToAdd(num);
|
const temp = Number(num);
|
||||||
|
setNumberOfAccountsToAdd(temp);
|
||||||
};
|
};
|
||||||
|
console.log("numberOfAccountsToAdd", numberOfAccountsToAdd);
|
||||||
const handleChangePaymentInput = (e, name) => {
|
const handleChangePaymentInput = (e, name) => {
|
||||||
const newPaymentData = handleFormDataChange(
|
const newPaymentData = handleFormDataChange(
|
||||||
e,
|
e,
|
||||||
@@ -323,8 +324,9 @@ const SignupPage = () => {
|
|||||||
}
|
}
|
||||||
// ******************** END STRIPE PAY API CALL ******************** //
|
// ******************** END STRIPE PAY API CALL ******************** //
|
||||||
|
|
||||||
const handleSignup = async (e) => {
|
const handleSignup = async (totalDue) => {
|
||||||
e.preventDefault();
|
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>handleSignup fired");
|
||||||
|
console.log("totalDue", totalDue);
|
||||||
const paymentDataValues = validatePaymentData();
|
const paymentDataValues = validatePaymentData();
|
||||||
if (paymentDataValues === null) {
|
if (paymentDataValues === null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -261,3 +261,10 @@
|
|||||||
margin-right: 12px;
|
margin-right: 12px;
|
||||||
padding-right: 12px;
|
padding-right: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.paymodal-summary-left-bonus {
|
||||||
|
color: #0008ea;
|
||||||
|
margin-top: -8px;
|
||||||
|
font-size: 0.82rem;
|
||||||
|
font-weight: 300;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user