Skip to content

Commit

Permalink
feat: 정답 모달 > 내 답안 보러가기 기능 추가
Browse files Browse the repository at this point in the history
[#2]
  • Loading branch information
YuHyun-P committed Dec 4, 2023
1 parent 13aa3af commit 20454bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion packages/frontend/src/hooks/useSolvedModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { useCallback, useState } from "react";

import useModal from "./useModal";

export function useSolvedModal() {
const LAST_QUIZ_ID = 19;

export function useSolvedModal(id: number) {
const [shareLink, setShareLink] = useState("");
const { modalOpen, openModal, closeModal } = useModal();

Expand All @@ -15,6 +17,7 @@ export function useSolvedModal() {
);

return {
lastQuiz: id === LAST_QUIZ_ID,
shareLink,
modalOpen,
openModal,
Expand Down
10 changes: 5 additions & 5 deletions packages/frontend/src/pages/quizzes/[id].page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import { isString } from "../../utils/typeGuard";
import * as styles from "./quiz.css";

export default function QuizPage({ quiz }: { quiz: Quiz }) {
const [{ terminalMode, editorFile, contentArray }, terminalDispatch] =
useReducer(terminalReducer, initialTerminalState);
const solvedModal = useSolvedModal();

const {
query: { id },
} = useRouter();

const solvedModal = useSolvedModal(isString(id) ? +id : -1);
const [{ terminalMode, editorFile, contentArray }, terminalDispatch] =
useReducer(terminalReducer, initialTerminalState);

const terminalInputRef = useRef<HTMLSpanElement>(null);

const handleTerminal = async (input: string) => {
Expand Down Expand Up @@ -155,7 +155,7 @@ export default function QuizPage({ quiz }: { quiz: Quiz }) {
{solvedModal.modalOpen && (
<SolvedModal
link={solvedModal.shareLink}
lastQuiz={false}
lastQuiz={solvedModal.lastQuiz}
onClose={solvedModal.closeModal}
onNextQuiz={console.log}
/>
Expand Down

0 comments on commit 20454bc

Please sign in to comment.