import { useMemo } from "react"; import Button from "../../pageElements/Button"; import Modal from "react-bootstrap/Modal"; import TextInput from "../../pageElements/TextInput"; import { splitEvery } from "../../Utils/Array"; import Col from "react-bootstrap/Col"; import Form from "react-bootstrap/Form"; import Row from "react-bootstrap/Row"; import "../../styles/modals.scss"; const PaymentModal = ({ isBusy, paymentData, paymentfields, handleChangePaymentInput, handleSignUp, setShowPaymentModal, handleSignup, selectedPlan, isAnnual, fieldsChunkSize, numberOfAccountsToAdd, }) => { const monthlyAddAccountPrice = selectedPlan[0].pricing[2].amount; const monthlySubscriptionPriceToday = selectedPlan[0].pricing[0].amount; const annualSubscriptionPriceToday = selectedPlan[0].pricing[1].amount * 12; const additionalAccountsMonthlyPriceToday = selectedPlan[0].pricing[2].amount ? selectedPlan[0].pricing[2].amount * numberOfAccountsToAdd : null; const additionalAccountsAnnualPriceToday = additionalAccountsMonthlyPriceToday * 12; const extraAccountsPrice = isAnnual ? additionalAccountsAnnualPriceToday ? additionalAccountsAnnualPriceToday : 0 : additionalAccountsMonthlyPriceToday ? additionalAccountsMonthlyPriceToday : 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 ? annualSubscriptionPriceToday : monthlySubscriptionPriceToday; const totalToday = amountToday + extraAccountsPrice; return ( Enter Payment Information
Order Summary
Subscription Type:
{planName}
Billing Period/Amount:
{billingPeriod} - ${amountToday}
{numberOfAccountsToAdd !== undefined && numberOfAccountsToAdd > 0 ? (
{numberOfAccountsToAdd} Addiitonal{" "} {numberOfAccountsToAdd > 1 ? `accounts:` : `account:`}
{billingPeriod} - ${extraAccountsPrice}
) : ( <> )}
Total today:
${totalToday}
{isAnnual ? (
Includes 15% discount for convenient annual billing
) : ( <> )}
{splitEvery(Object.keys(paymentfields), fieldsChunkSize).map( (names, j) => ( {j === 2 ? (
Card Expiration Date
) : ( <> )} {names.map((name, i) => ( handleChangePaymentInput(e, name)} error={paymentData[name].error} message={paymentData[name].message} label={ paymentData[name].value.length === 0 ? paymentfields[name].label : "" } type={paymentfields[name].type} values={paymentfields[name].values} disabled={isBusy} inputClassName={ j === 2 ? "skinny-input" : j === 1 && i === 1 ? "skinny-input" : null } /> ))}
) )}