mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-09-03 14:22:41 +02:00
fix: progress percentage
This commit is contained in:
@@ -25,6 +25,7 @@ import { AICourseFooter } from './AICourseFooter';
|
|||||||
import { ForkCourseAlert } from './ForkCourseAlert';
|
import { ForkCourseAlert } from './ForkCourseAlert';
|
||||||
import { ForkCourseConfirmation } from './ForkCourseConfirmation';
|
import { ForkCourseConfirmation } from './ForkCourseConfirmation';
|
||||||
import { useAuth } from '../../hooks/use-auth';
|
import { useAuth } from '../../hooks/use-auth';
|
||||||
|
import { getPercentage } from '../../lib/number';
|
||||||
|
|
||||||
type AICourseContentProps = {
|
type AICourseContentProps = {
|
||||||
courseSlug?: string;
|
courseSlug?: string;
|
||||||
@@ -134,8 +135,9 @@ export function AICourseContent(props: AICourseContentProps) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const totalDoneLessons = (course?.done || []).length;
|
const totalDoneLessons = (course?.done || []).length;
|
||||||
const finishedPercentage = Math.round(
|
const finishedPercentage = getPercentage(
|
||||||
(totalDoneLessons / totalCourseLessons) * 100,
|
totalDoneLessons,
|
||||||
|
totalCourseLessons,
|
||||||
);
|
);
|
||||||
|
|
||||||
const modals = (
|
const modals = (
|
||||||
@@ -313,7 +315,7 @@ export function AICourseContent(props: AICourseContentProps) {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{finishedPercentage > 0 && (
|
{finishedPercentage > 0 && !isLoading && (
|
||||||
<>
|
<>
|
||||||
<span className="text-gray-400">•</span>
|
<span className="text-gray-400">•</span>
|
||||||
<span className="font-medium text-green-600">
|
<span className="font-medium text-green-600">
|
||||||
|
Reference in New Issue
Block a user