Skip to content

Commit

Permalink
feat: update progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinan029 committed Aug 28, 2024
1 parent a4bd4f8 commit 4220836
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const CourseSection = ({
},
);
};

const [progress, setProgress] = useState({});
const fetchData = useCallback(
async (courseRun) => {
Expand All @@ -121,7 +121,8 @@ const CourseSection = ({
useEffect(() => {

Check failure on line 121 in src/components/dashboard/main-content/course-enrollments/CourseSection.jsx

View workflow job for this annotation

GitHub Actions / tests (18)

React Hook "useEffect" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function

Check failure on line 121 in src/components/dashboard/main-content/course-enrollments/CourseSection.jsx

View workflow job for this annotation

GitHub Actions / tests (20)

React Hook "useEffect" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function
fetchData(courseRun.courseRunId);
}, [fetchData]);

Check failure on line 123 in src/components/dashboard/main-content/course-enrollments/CourseSection.jsx

View workflow job for this annotation

GitHub Actions / tests (18)

React Hook useEffect has a missing dependency: 'courseRun.courseRunId'. Either include it or remove the dependency array. Outer scope values like 'fetchData' aren't valid dependencies because mutating them doesn't re-render the component

Check failure on line 123 in src/components/dashboard/main-content/course-enrollments/CourseSection.jsx

View workflow job for this annotation

GitHub Actions / tests (20)

React Hook useEffect has a missing dependency: 'courseRun.courseRunId'. Either include it or remove the dependency array. Outer scope values like 'fetchData' aren't valid dependencies because mutating them doesn't re-render the component

const numTotalUnits = progress?.completionSummary?.completeCount + progress?.completionSummary?.incompleteCount + progress?.completionSummary?.lockedCount;

Check failure on line 124 in src/components/dashboard/main-content/course-enrollments/CourseSection.jsx

View workflow job for this annotation

GitHub Actions / tests (18)

This line has a length of 159. Maximum allowed is 120

Check failure on line 124 in src/components/dashboard/main-content/course-enrollments/CourseSection.jsx

View workflow job for this annotation

GitHub Actions / tests (18)

Unsafe arithmetic operation on optional chaining. It can result in NaN

Check failure on line 124 in src/components/dashboard/main-content/course-enrollments/CourseSection.jsx

View workflow job for this annotation

GitHub Actions / tests (18)

Unsafe arithmetic operation on optional chaining. It can result in NaN

Check failure on line 124 in src/components/dashboard/main-content/course-enrollments/CourseSection.jsx

View workflow job for this annotation

GitHub Actions / tests (18)

Unsafe arithmetic operation on optional chaining. It can result in NaN

Check failure on line 124 in src/components/dashboard/main-content/course-enrollments/CourseSection.jsx

View workflow job for this annotation

GitHub Actions / tests (20)

This line has a length of 159. Maximum allowed is 120

Check failure on line 124 in src/components/dashboard/main-content/course-enrollments/CourseSection.jsx

View workflow job for this annotation

GitHub Actions / tests (20)

Unsafe arithmetic operation on optional chaining. It can result in NaN

Check failure on line 124 in src/components/dashboard/main-content/course-enrollments/CourseSection.jsx

View workflow job for this annotation

GitHub Actions / tests (20)

Unsafe arithmetic operation on optional chaining. It can result in NaN

Check failure on line 124 in src/components/dashboard/main-content/course-enrollments/CourseSection.jsx

View workflow job for this annotation

GitHub Actions / tests (20)

Unsafe arithmetic operation on optional chaining. It can result in NaN
const completePercentage = progress?.completionSummary?.completeCount ? Number(((progress?.completionSummary?.completeCount / numTotalUnits) * 100).toFixed(0)) : 0;
if (isAuditEnrollment && courseRun.courseRunStatus === COURSE_STATUSES.inProgress) {
return (
<Suspense
Expand All @@ -133,14 +134,17 @@ const CourseSection = ({
</DelayedFallbackContainer>
)}
>
<Component {...getCourseRunProps(courseRun)} />
<div>
<Component
{...getCourseRunProps(courseRun)}
key={courseRun.courseRunId}
/>
<ProgressBar now={`${completePercentage}%`} label={`${completePercentage}%`} variant="primary" />
<br />
</div>
</Suspense>
);
}

const numTotalUnits = progress?.completionSummary?.completeCount + progress?.completionSummary?.incompleteCount + progress?.completionSummary?.lockedCount;
const completePercentage = progress?.completionSummary?.completeCount ? Number(((progress?.completionSummary?.completeCount / numTotalUnits) * 100).toFixed(0)) : 0;
console.log(completePercentage)
return (
<div>
<Component
Expand Down

0 comments on commit 4220836

Please sign in to comment.