Skip to content

Commit

Permalink
refactor: change calculate remainCredit
Browse files Browse the repository at this point in the history
  • Loading branch information
yougyung committed Sep 13, 2024
1 parent 5a0c9ca commit e8e5023
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/ui/user/user-info-card/user-info-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ function UserInfoContent({ data }: UserInfoContentProps) {
const { studentNumber, studentName, completeDivision: majors, totalCredit, takenCredit, graduated } = data;

const remainCredit = categories.reduce((accumulator, category) => {
if (category.category === 'CHAPEL') return accumulator;
return accumulator + (category.totalCredit - category.takenCredit);
const { category: categoryName, totalCredit, takenCredit } = category;
if (categoryName === 'CHAPEL') return accumulator;
const categoryRemainCredit = totalCredit - takenCredit < 0 ? 0 : totalCredit - takenCredit;
return accumulator + categoryRemainCredit;
}, 0);

const percentage = getPercentage(totalCredit - remainCredit, totalCredit);
Expand Down

0 comments on commit e8e5023

Please sign in to comment.