diff --git a/app/(game)/play/PlayClient.tsx b/app/(game)/play/PlayClient.tsx index 05e9736..a650cd7 100644 --- a/app/(game)/play/PlayClient.tsx +++ b/app/(game)/play/PlayClient.tsx @@ -38,13 +38,13 @@ export default function PlayClient({ problemCount }: PlayClientProps) { const [answerB, setAnswerB] = useState(""); const [inputError, setInputError] = useState(""); + const sessionProblemCount = session?.problems.length ?? null; const currentProblem = session?.problems[session.currentIndex] ?? null; const currentResult = session?.results[session.currentIndex] ?? null; const isComplete = Boolean( session && session.currentIndex >= session.problems.length, ); - const sessionNeedsInit = - session === null || session.problems.length !== problemCount; + const sessionNeedsInit = sessionProblemCount !== problemCount; const correctCount = session?.results.filter((result) => result?.correct).length ?? 0; const totalCount = session?.problems.length ?? 0; @@ -61,7 +61,7 @@ export default function PlayClient({ problemCount }: PlayClientProps) { initSession, problemCount, selectedProblemCount, - session, + sessionProblemCount, sessionNeedsInit, setProblemCount, ]); @@ -89,7 +89,7 @@ export default function PlayClient({ problemCount }: PlayClientProps) { submitAnswer({ a: parsedA, b: parsedB }); } - if (sessionNeedsInit) { + if (!session || sessionNeedsInit) { return (
diff --git a/app/(game)/play/page.tsx b/app/(game)/play/page.tsx index c1becd5..852ea12 100644 --- a/app/(game)/play/page.tsx +++ b/app/(game)/play/page.tsx @@ -3,11 +3,15 @@ import type { ProblemCount } from "@/store/gameStore"; interface PlayPageProps { searchParams?: { - count?: string; + count?: string | string[]; }; } -function parseProblemCount(count?: string): ProblemCount { +function parseProblemCount(count?: string | string[]): ProblemCount { + if (Array.isArray(count)) { + return parseProblemCount(count[0]); + } + return count === "5" ? 5 : 10; } diff --git a/app/page.tsx b/app/page.tsx index 836d737..48be922 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -6,7 +6,7 @@ export default function Home() {

- 중학교 2학년 수학 실수 유형 연습 + 중학교 2학년 수학 - 괄호 풀기 연습

괄호 음수 분배 연습