Skip to content

Commit

Permalink
feat: 파트순 정렬 && 이름 가나다순 정렬
Browse files Browse the repository at this point in the history
  • Loading branch information
cjy3458 committed May 5, 2024
1 parent 0377bc4 commit 8d79a43
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/mypage/TotalScoreSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const TotalScoreSection = ({ myName }: { myName: string }) => {
const [clickedUser, setClickedUser] = useState<UserScore>({} as UserScore);
const scoreChanged = useRecoilValue(userScoreChanged);
const [isPre, setIsPre] = useState<boolean>(false);
const [sortScoreArray, setSortScoreArray] = useState<UserScore[]>([]);

useEffect(() => {
if (myName === '최재영' || myName === '박재윤') {
Expand Down Expand Up @@ -59,8 +60,18 @@ const TotalScoreSection = ({ myName }: { myName: string }) => {
}
});
setTotalScoreArray(Object.values(tmpObject));
const sort = totalScoreArray.sort((a: UserScore, b: UserScore) => {
if (a.track !== b.track) {
return a.track - b.track;
}
return a.name.localeCompare(b.name, 'ko');
});
setSortScoreArray(sort);
}
}, [totalAssignment, totalAttendance]);

if (totalScoreArray) {
}
return (
<>
<Wrapper>
Expand All @@ -77,7 +88,7 @@ const TotalScoreSection = ({ myName }: { myName: string }) => {
</ScoreTitle>
))}
</ScoreRow>
{totalScoreArray.map((userScore, i) => (
{sortScoreArray.map((userScore, i) => (
<ScoreRow index={i + 1} key={i}>
<Score>
{userScore.name}
Expand Down

0 comments on commit 8d79a43

Please sign in to comment.