diff --git a/src/Components/Modals/PaymentModal.js b/src/Components/Modals/PaymentModal.js index a76bb5b..8c494b0 100644 --- a/src/Components/Modals/PaymentModal.js +++ b/src/Components/Modals/PaymentModal.js @@ -1,3 +1,4 @@ +import { useMemo } from "react"; import Button from "../../pageElements/Button"; import Modal from "react-bootstrap/Modal"; import TextInput from "../../pageElements/TextInput"; @@ -8,12 +9,10 @@ import Row from "react-bootstrap/Row"; import "../../styles/modals.scss"; const PaymentModal = ({ - buttonLabelText, isBusy, paymentData, paymentfields, handleChangePaymentInput, - orderSummary, handleSignUp, setShowPaymentModal, handleSignup, @@ -23,18 +22,39 @@ const PaymentModal = ({ numberOfAccountsToAdd, }) => { 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 = (selectedPlan[0]?.value === "partner" && numberOfAccountsToAdd > 0) || (selectedPlan[0]?.value === "seniorPartner" && numberOfAccountsToAdd > 0); + const planName = selectedPlan[0].name ? selectedPlan[0].name : null; const billingPeriod = isAnnual ? "Annually" : "Monthly"; const amountToday = isAnnual - ? selectedPlan[0]?.pricing[0]?.amount - : selectedPlan[0]?.pricing[1]?.amount; - console.log("annualAddAccountPrice", annualAddAccountPrice); - console.log("isAnnual", isAnnual); - console.log("numberOfAccountsToAdd", numberOfAccountsToAdd); + ? annualSubscriptionPriceToday + : monthlySubscriptionPriceToday; + const totalToday = amountToday + extraAccountsPrice; + console.log("amoutnToday", amountToday); + console.log("extraAccountsPrice", extraAccountsPrice); + + function handleValidateAndPay() { + handleSignup(totalToday); + } return ( @@ -48,7 +68,6 @@ const PaymentModal = ({
Subscription Type:
{planName}
-
Billing Period/Amount: @@ -57,25 +76,29 @@ const PaymentModal = ({ {billingPeriod} - ${amountToday}
- {showAdditionaLAccountsView ? ( + {numberOfAccountsToAdd !== undefined && + numberOfAccountsToAdd > 0 ? (
- Additional Accounts: + {numberOfAccountsToAdd} Addiitonal{" "} + {numberOfAccountsToAdd > 1 ? `accounts` : `account`}
- {isAnnual ? ( -

- {" "} - {numberOfAccountsToAdd}/ x 12 months = $ - {annualAddAccountPrice} -

- ) : ( -

- {" "} - {numberOfAccountsToAdd}/per month = $ - {monthlyAddAccountPrice} -

- )} + {billingPeriod} - ${extraAccountsPrice} +
+
+ ) : ( + <> + )} +
+
Total today:
+
${totalToday}
+
+ {isAnnual ? ( +
+
+
+ Includes 10% discount for convenient annual billing
) : ( @@ -126,7 +149,7 @@ const PaymentModal = ({