Skip to content

Commit

Permalink
Fix: 사이트 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
chchaeun committed Sep 21, 2022
1 parent 582f4cd commit d03e83e
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 23 deletions.
1 change: 1 addition & 0 deletions api/quizzes/my-quizzes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ export const fetchMyQuizzes = async ({ challengeId, week }: Props) => {
week: week ? week : 0,
},
});

return data;
};
4 changes: 2 additions & 2 deletions components/challenges/containers/progress-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ function ChallengeProgressContainer({ challengeId }: Props) {
(week) => week.status === "UNREADABLE"
).length;

if (successOrFail === "success") {
if (successOrFail === "SUCCESS") {
return successCount;
} else if (successOrFail === "fail") {
} else if (successOrFail === "FAIL") {
return failCount;
} else {
return challengeDetail!.totalWeeks - successCount - failCount;
Expand Down
12 changes: 1 addition & 11 deletions components/layout/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const Container = styled.div`
background: #ffffff;
border-bottom: 1px solid #f1f5f9;
z-index: 10;
z-index: 20;
${media.medium`
padding: 10px 16px;
Expand Down Expand Up @@ -96,11 +96,9 @@ const Navigation = styled.nav`
padding: 0px;
gap: 32px;
width: 280px;
height: 36px;
${media.medium`
width: 160px;
gap: 20px;
`}
`;
Expand All @@ -112,16 +110,10 @@ const Ul = styled.ul`
padding: 0px;
gap: 24px;
width: 168px;
height: 16px;
${media.medium`
width: 70px;
`}
`;

const Li = styled.li<{ showInMedium?: boolean }>`
width: 76px;
height: 16px;
font-style: normal;
Expand All @@ -143,7 +135,6 @@ const Button = styled.button`
padding: 10px;
gap: 10px;
width: 84px;
height: 36px;
background: #171717;
Expand All @@ -154,7 +145,6 @@ const Button = styled.button`
line-height: 16px;
${media.medium`
width: 77px;
font-size: 12px;
`}
`;
4 changes: 2 additions & 2 deletions components/quizzes/blocks/quiz-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function QuizList({ challengeId, week, page }: Props) {
});

// page에 따라 퀴즈 상세페이지로 이동하는 href를 설정해주는 함수이다.
const getHrefByPage = (quizId: number) => {
const getLinkByPage = (quizId: number) => {
const LINK_HEAD = `/challenges/${challengeId}/quizzes/${quizId}`;
switch (page) {
case "MY":
Expand All @@ -45,7 +45,7 @@ function QuizList({ challengeId, week, page }: Props) {
</thead>
<tbody>
{quizzes?.map((quiz) => (
<Link href={getHrefByPage(quiz.quizId)} key={quiz.quizId}>
<Link href={getLinkByPage(quiz.quizId)} key={quiz.quizId}>
<tr className="cursor-pointer sm:text-sm">
<td>{quiz.quizId}</td>
<td>{quiz.quizTitle}</td>
Expand Down
39 changes: 34 additions & 5 deletions hooks/quizzes-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,49 @@ export default function useQuizzesQuery({
page,
suspense = false,
}: Props) {
const queryKey = [page, challengeId];
const queryKey = ["quizzes", page, challengeId];
let queryFn;
let queryOptions;
switch (page) {
case "READABLE":
queryFn = () => fetchQuizzes({ challengeId, week: week || "" });
queryOptions = { enabled: !!(challengeId && week), suspense };
queryOptions = {
enabled: !!(challengeId && week),
suspense,
select: (data: QuizSummary[]) => {
const orderData = data.sort(function (a, b) {
return +new Date(b.quizCreatedDate) - +new Date(a.quizCreatedDate);
});
return orderData;
},
};
break;
case "MY":
queryFn = () => fetchMyQuizzes({ challengeId });
queryOptions = { enabled: !!challengeId, suspense };
queryOptions = {
enabled: !!challengeId,
suspense,
select: (data: QuizSummary[]) => {
const orderData = data.sort(function (a, b) {
return +new Date(b.quizCreatedDate) - +new Date(a.quizCreatedDate);
});
return orderData;
},
};
break;
case "LIKED":
queryFn = () => fetchLikedQuizzes({ challengeId });
queryOptions = { enabled: !!challengeId, suspense };
queryOptions = {
enabled: !!challengeId,
suspense,
select: (data: QuizSummary[]) => {
const orderData = data.sort(function (a, b) {
return +new Date(b.quizCreatedDate) - +new Date(a.quizCreatedDate);
});
return orderData;
},
};
break;
}

return useQuery<QuizSummary[]>(queryKey, queryFn, queryOptions);
}
2 changes: 1 addition & 1 deletion pages/challenges/[cid]/quizzes/my.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function MyQuizListPage() {
<>
<ChallengeOverview challengeId={challengeId} />
<div className="flex flex-col gap-6 py-5 px-10 bg-white rounded-lg shadow-sm border-[1px] border-gray-300 sm:px-5">
<div className="font-semibold">내가 낸 문제</div>
<div className="font-semibold">제출한 문제</div>
<Suspense fallback={<QuizListSkeleton />}>
<QuizList challengeId={challengeId} page={"MY"} />
</Suspense>
Expand Down
2 changes: 1 addition & 1 deletion pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function Dashboard() {
}
);
return (
<div className="flex flex-col gap-10 m-auto py-[80px] px-[200px] sm:py-[88px] sm:px-[12px]">
<div className="flex flex-col gap-10 m-auto py-[80px] px-[200px] sm:py-[88px] sm:px-[50px]">
<div className="text-2xl">내 챌린지</div>
{myChallenges && <ChallengeList challenges={myChallenges} />}
</div>
Expand Down
2 changes: 1 addition & 1 deletion public/sw.js

Large diffs are not rendered by default.

0 comments on commit d03e83e

Please sign in to comment.