import NumberPlayClient from "./NumberPlayClient";
import type { ProblemCount } from "@/store/gameStore";

interface NumberPlayPageProps {
  searchParams?: {
    count?: string | string[];
  };
}

function parseProblemCount(count?: string | string[]): ProblemCount {
  if (Array.isArray(count)) {
    return parseProblemCount(count[0]);
  }

  return count === "5" ? 5 : 10;
}

export default function NumberPlayPage({ searchParams }: NumberPlayPageProps) {
  return (
    <NumberPlayClient problemCount={parseProblemCount(searchParams?.count)} />
  );
}
