From 1ce386ac3bd48622ffc35a43ab016ce3a5ce344a Mon Sep 17 00:00:00 2001 From: tunny17 Date: Mon, 4 Sep 2023 09:09:09 +0000 Subject: [PATCH] CLASSROOMIO-T-136: Discount Logic Fix Co-authored-by: Tunji Adeyemi Merge-request: CLASSROOMIO-MR-64 Merged-by: Best Admin --- .../components/PricingSection.svelte | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/lib/components/CourseLandingPage/components/PricingSection.svelte b/src/lib/components/CourseLandingPage/components/PricingSection.svelte index 0061664f..8da9e409 100644 --- a/src/lib/components/CourseLandingPage/components/PricingSection.svelte +++ b/src/lib/components/CourseLandingPage/components/PricingSection.svelte @@ -9,7 +9,7 @@ export let courseData: Course = { id: '', title: '', - description: '', + description: '' }; let calculatedCost = 0; @@ -18,7 +18,9 @@ function calcDisc(percent: number, cost: number) { if (!percent) return cost; - return Math.round((percent / 100) * cost) || cost; + const discountAmount = (percent / 100) * cost; + const discountedPrice = cost - discountAmount; + return Math.round(discountedPrice); } function addToCart() {} @@ -36,9 +38,7 @@ -