Skip to content

Commit ecc0030

Browse files
committed
addon bug fix
Signed-off-by: Namanv509 <namanverma00260@gmail.com>
1 parent a1d21ae commit ecc0030

1 file changed

Lines changed: 35 additions & 26 deletions

File tree

  • src/components/Pricing/PricingAddons

src/components/Pricing/PricingAddons/index.js

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -477,32 +477,41 @@ export const PricingAddons = ({ isYearly = false, setIsYearly ,currency,enterpri
477477

478478
<Box sx={{ ...boxStyles.flexColumn, ...boxStyles.pricingItems }}>
479479
<Box sx={boxStyles.flexBetween}>
480-
<Typography variant="body1" sx={typographyStyles.pricingItemLeft}>
481-
{selectedAddon?.id === "academy" ?
482-
`Theoretical Learning × ${selectedAddon?.subAddOns?.find(sub => sub.id === "academy-theory")?.pricing?.[quantityIndex]?.learners || 0}` :
483-
`${selectedAddon?.name} × ${quantity} x ${selectedAddon?.cadence}`
484-
}
485-
</Typography>
486-
<Typography variant="body1" fontWeight="500" sx={typographyStyles.pricingItemRight}>
487-
{(() => {
488-
if (selectedAddon?.id === "academy") {
489-
const theorySubAddon = selectedAddon?.subAddOns?.find(sub => sub.id === "academy-theory");
490-
if (theorySubAddon?.pricing && theorySubAddon.pricing[quantityIndex]) {
491-
const currentLearnerOption = theorySubAddon.pricing[quantityIndex];
492-
const monthlyPerUserCost = currentLearnerOption.monthlyPerUser;
493-
const yearlyPerUserCost = currentLearnerOption.yearlyPerUser;
494-
const totalCost = isYearly
495-
? yearlyPerUserCost * currentLearnerOption.learners
496-
: monthlyPerUserCost * currentLearnerOption.learners;
497-
return formatPrice(totalCost);
498-
}
499-
return formatPrice(0);
500-
} else {
501-
return formatPrice((isYearly ? selectedAddon?.yearlyPrice : selectedAddon?.monthlyPrice) * quantity);
502-
}
503-
})()}
504-
</Typography>
505-
</Box>
480+
<Typography variant="body1" sx={typographyStyles.pricingItemLeft}>
481+
{selectedAddon?.id === "academy" ?
482+
`Theoretical Learning × ${selectedAddon?.subAddOns?.find(sub => sub.id === "academy-theory")?.pricing?.[quantityIndex]?.learners || 0}` :
483+
`${selectedAddon?.name} × ${selectedAddon?.pricing?.[quantityIndex]?.units || 0}`
484+
}
485+
</Typography>
486+
<Typography variant="body1" fontWeight="500" sx={typographyStyles.pricingItemRight}>
487+
{(() => {
488+
if (selectedAddon?.id === "academy") {
489+
const theorySubAddon = selectedAddon?.subAddOns?.find(sub => sub.id === "academy-theory");
490+
if (theorySubAddon?.pricing && theorySubAddon.pricing[quantityIndex]) {
491+
const currentLearnerOption = theorySubAddon.pricing[quantityIndex];
492+
const monthlyPerUserCost = currentLearnerOption.monthlyPerUser;
493+
const yearlyPerUserCost = currentLearnerOption.yearlyPerUser;
494+
const totalCost = isYearly
495+
? yearlyPerUserCost * currentLearnerOption.learners
496+
: monthlyPerUserCost * currentLearnerOption.learners;
497+
return formatPrice(totalCost);
498+
}
499+
return formatPrice(0);
500+
} else {
501+
if (selectedAddon?.pricing && selectedAddon.pricing[quantityIndex]) {
502+
const currentOption = selectedAddon.pricing[quantityIndex];
503+
const monthlyPerUnitCost = currentOption.monthlyPerUnit;
504+
const yearlyPerUnitCost = currentOption.yearlyPerUnit;
505+
const totalCost = isYearly
506+
? yearlyPerUnitCost * currentOption.units
507+
: monthlyPerUnitCost * currentOption.units;
508+
return formatPrice(totalCost);
509+
}
510+
return formatPrice(0);
511+
}
512+
})()} /{isYearly ? "yearly" : "monthly"}
513+
</Typography>
514+
</Box>
506515

507516
{selectedAddon?.id === "academy" && selectedAddon.subAddOns?.map((subAddOn) => (
508517
selectedSubAddOns[subAddOn.id] && subAddOn.id !== "academy-theory" && (

0 commit comments

Comments
 (0)