fix discount bug + font dif on lesson page

This commit is contained in:
Rotimi Best
2023-09-26 23:29:50 +01:00
parent 92eef283f1
commit e3d0db15f2
4 changed files with 154 additions and 144 deletions
@@ -21,8 +21,8 @@
let formatter: Intl.NumberFormat | undefined;
let isFree = false;
function calcDisc(percent: number, cost: number) {
if (!percent) return cost;
function calcDisc(percent: number, cost: number, showDiscount: boolean) {
if (!percent || !showDiscount) return cost;
const discountAmount = (percent / 100) * cost;
const discountedPrice = cost - discountAmount;
return Math.round(discountedPrice);
@@ -51,8 +51,9 @@
}
$: setFormatter(courseData.currency);
$: discount = get(courseData, 'metadata.discount', 0);
$: calculatedCost = calcDisc(discount, courseData.cost || 0);
$: calculatedCost = calcDisc(discount, courseData.cost || 0, courseData.metadata.showDiscount);
$: isFree = isCourseFree(calculatedCost);
</script>