Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
FIX: 마이스터 랭킹 비공개 버튼 누르고 취소 시 다른 페이지로 이동하는 문제
Browse files Browse the repository at this point in the history
  • Loading branch information
leehj050211 committed Mar 27, 2023
1 parent aea60b5 commit 12b0d96
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion components/common/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const Sidebar = () => {
<SidebarItem
Icon={AiFillGithub}
iconSize={26}
onClick={() => window.location.href = 'https://github.com/BSSM-BSM'}
onClick={() => window.open('https://github.com/BSSM-BSM', '_blank')}
>
깃허브
</SidebarItem>
Expand Down
51 changes: 28 additions & 23 deletions components/meister/rankingItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { useRecoilState } from 'recoil';
import { userState } from '../../store/account.store';
import styles from '../../styles/meister/ranking.module.css';
Expand All @@ -13,6 +13,7 @@ interface MeisterRankingItemProps {
}

export const MeisterRankingItem = ({ ranking, i, updatePrivateRanking }: MeisterRankingItemProps) => {
const router = useRouter();
const [user] = useRecoilState(userState);
const { grade, classNo, studentNo, name } = ranking.student;

Expand Down Expand Up @@ -41,30 +42,34 @@ export const MeisterRankingItem = ({ ranking, i, updatePrivateRanking }: Meister
}
}

const myRankingCheck = (): boolean => (
user.isLogin && user.role === UserRole.STUDENT &&
grade === user.student.grade &&
classNo === user.student.classNo &&
studentNo === user.student.studentNo
);

const viewMyMeisterInfo = () => router.push(`/meister?grade=${grade}&classNo=${classNo}&studentNo=${studentNo}`);

return (
<li>
<Link className={styles.item} href={`/meister?grade=${grade}&classNo=${classNo}&studentNo=${studentNo}`}>
<div className={styles.rank}>{i + 1}</div>
<div className={styles.info_wrap}>
<div className={styles.student_info}>
<span>
{`${grade}${classNo}${String(studentNo).padStart(2, '0')}`}
</span>
<span>{name}</span>
{
user.isLogin && user.role === UserRole.STUDENT &&
grade === user.student.grade &&
classNo === user.student.classNo &&
studentNo === user.student.studentNo &&
ranking.result !== MeisterResultType.LOGIN_ERROR &&
<span onClick={() => updatePrivateRanking(true)}>비공개로 변경</span>
}
</div>
<div className={styles.score_info_wrap}>
{scoreInfoView()}
</div>
<li className={styles.item} onClick={() => !myRankingCheck() && viewMyMeisterInfo()}>
<div className={styles.rank}>{i + 1}</div>
<div className={styles.info_wrap}>
<div className={styles.student_info}>
<span>
{`${grade}${classNo}${String(studentNo).padStart(2, '0')}`}
</span>
<span>{name}</span>
{
myRankingCheck() &&
ranking.result !== MeisterResultType.LOGIN_ERROR &&
<span onClick={() => updatePrivateRanking(true)}>비공개로 변경</span>
}
</div>
<div className={styles.score_info_wrap}>
{scoreInfoView()}
</div>
</Link>
</div>
</li>
)
};

0 comments on commit 12b0d96

Please sign in to comment.