괄호 안의 항을 2, 3, 4 항으로 설정하는 기능 추가
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import NumberPlayClient from "./NumberPlayClient";
|
||||
import type { ProblemCount } from "@/store/gameStore";
|
||||
import type { MaxTermCount, ProblemCount } from "@/store/gameStore";
|
||||
|
||||
interface NumberPlayPageProps {
|
||||
searchParams?: {
|
||||
count?: string | string[];
|
||||
terms?: string | string[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,8 +16,22 @@ function parseProblemCount(count?: string | string[]): ProblemCount {
|
||||
return count === "5" ? 5 : 10;
|
||||
}
|
||||
|
||||
function parseMaxTermCount(terms?: string | string[]): MaxTermCount {
|
||||
if (Array.isArray(terms)) {
|
||||
return parseMaxTermCount(terms[0]);
|
||||
}
|
||||
|
||||
if (terms === "3") return 3;
|
||||
if (terms === "4") return 4;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
export default function NumberPlayPage({ searchParams }: NumberPlayPageProps) {
|
||||
return (
|
||||
<NumberPlayClient problemCount={parseProblemCount(searchParams?.count)} />
|
||||
<NumberPlayClient
|
||||
problemCount={parseProblemCount(searchParams?.count)}
|
||||
maxTermCount={parseMaxTermCount(searchParams?.terms)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user