Skip to content

Commit 5379aec

Browse files
authored
fix: ai course progress percentage (kamranahmedse#8781)
1 parent f417fd4 commit 5379aec

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/components/GenerateCourse/AICourseContent.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { AICourseFooter } from './AICourseFooter';
2525
import { ForkCourseAlert } from './ForkCourseAlert';
2626
import { ForkCourseConfirmation } from './ForkCourseConfirmation';
2727
import { useAuth } from '../../hooks/use-auth';
28+
import { getPercentage } from '../../lib/number';
2829

2930
type AICourseContentProps = {
3031
courseSlug?: string;
@@ -134,8 +135,9 @@ export function AICourseContent(props: AICourseContentProps) {
134135
);
135136

136137
const totalDoneLessons = (course?.done || []).length;
137-
const finishedPercentage = Math.round(
138-
(totalDoneLessons / totalCourseLessons) * 100,
138+
const finishedPercentage = getPercentage(
139+
totalDoneLessons,
140+
totalCourseLessons,
139141
);
140142

141143
const modals = (
@@ -313,7 +315,7 @@ export function AICourseContent(props: AICourseContentProps) {
313315
</span>
314316
)}
315317

316-
{finishedPercentage > 0 && (
318+
{finishedPercentage > 0 && !isLoading && (
317319
<>
318320
<span className="text-gray-400"></span>
319321
<span className="font-medium text-green-600">

0 commit comments

Comments
 (0)