From 333a54357b43b9e44c7a5339def1035bbe9b0d42 Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Fri, 13 Jun 2025 11:01:21 +0600 Subject: [PATCH] fix: progress percentage --- src/components/GenerateCourse/AICourseContent.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/GenerateCourse/AICourseContent.tsx b/src/components/GenerateCourse/AICourseContent.tsx index ba484cd76..1e253eb54 100644 --- a/src/components/GenerateCourse/AICourseContent.tsx +++ b/src/components/GenerateCourse/AICourseContent.tsx @@ -25,6 +25,7 @@ import { AICourseFooter } from './AICourseFooter'; import { ForkCourseAlert } from './ForkCourseAlert'; import { ForkCourseConfirmation } from './ForkCourseConfirmation'; import { useAuth } from '../../hooks/use-auth'; +import { getPercentage } from '../../lib/number'; type AICourseContentProps = { courseSlug?: string; @@ -134,8 +135,9 @@ export function AICourseContent(props: AICourseContentProps) { ); const totalDoneLessons = (course?.done || []).length; - const finishedPercentage = Math.round( - (totalDoneLessons / totalCourseLessons) * 100, + const finishedPercentage = getPercentage( + totalDoneLessons, + totalCourseLessons, ); const modals = ( @@ -313,7 +315,7 @@ export function AICourseContent(props: AICourseContentProps) { )} - {finishedPercentage > 0 && ( + {finishedPercentage > 0 && !isLoading && ( <>