Skip to content

Commit

Permalink
chore(meister): meister page 전역 state로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubinquitous committed Dec 26, 2023
1 parent b5441c9 commit 94185ad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/templates/meister/layouts/Ranking.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import styled from "styled-components";
import { Category } from "@/components/atoms";
import { useDidMountEffect } from "@/hooks";
import { flex, font } from "@/styles";
import { useUser } from "@/@user/hooks";
import { useMeisterRankingQuery } from "../services/query.service";
Expand All @@ -12,9 +13,10 @@ const Ranking = () => {
const [currentGrade, setCurrentGrade] = React.useState(user.grade);
const { data, isSuccess, refetch } = useMeisterRankingQuery(currentGrade);

React.useEffect(() => {
useDidMountEffect(() => {
refetch();
}, [currentGrade, refetch]);
// eslint-disable-next-line
}, [currentGrade]);

return (
<Container>
Expand Down
27 changes: 19 additions & 8 deletions src/templates/meister/layouts/RankingListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import styled from "styled-components";
import { Column, Row } from "@/components/Flex";
import { theme, font, flex } from "@/styles";
import { useSetAtom } from "jotai";
import { studentNumberContext, buttonSwitchContext } from "../context";
import { getStudentId } from "../helpers";

interface MeisterProfileBoxProps {
score: number;
Expand All @@ -22,24 +25,31 @@ const RankingListItem = ({
negativePoint,
index,
}: MeisterProfileBoxProps) => {
const { grade, classNo, studentNo } = student;
const setStudentNum = useSetAtom(studentNumberContext);
const setSwitch = useSetAtom(buttonSwitchContext);

const handleContainerButtonClick = () => {
setStudentNum(getStudentId(grade, classNo, studentNo));
setSwitch(true);
};

return (
<Container>
<Container onClick={handleContainerButtonClick}>
<RankText>{index}</RankText>
<Column>
<Row alignItems="center" gap="5px">
<Department>
{student.grade >= 2 ? (
<span>
{student.classNo <= 2 ? "소프트웨어" : "임베디드소프트웨어"}
</span>
{grade >= 2 ? (
<span>{classNo <= 2 ? "소프트웨어" : "임베디드소프트웨어"}</span>
) : (
"통합"
)}
개발과
</Department>
<Grade>{student.grade}학년</Grade>
<ClassNo>{student.classNo}</ClassNo>
<StudentNo>{student.studentNo}</StudentNo>
<Grade>{grade}학년</Grade>
<ClassNo>{classNo}</ClassNo>
<StudentNo>{studentNo}</StudentNo>
<Name>{student.name}</Name>
</Row>
<MeisterPoint>마이스터역량인증제 점수 ㆍ {score}</MeisterPoint>
Expand All @@ -60,6 +70,7 @@ const Container = styled.div`
display: flex;
align-items: center;
gap: 18px;
cursor: pointer;
`;

const RankText = styled.div`
Expand Down

0 comments on commit 94185ad

Please sign in to comment.