import { useEffect } from "react"
import useStore from "../utils/store"

export const ParamsChecker = () => {
  const setMode = useStore((state) => state.setMode)

  useEffect(() => {
    const params = new URLSearchParams(window.location.search)
    const mode = params.get("mode")
    if (mode && ["teacher", "student"].includes(mode.toLowerCase())) {
      console.log("Setting mode to ", mode.toLowerCase())
      setMode(mode.toLowerCase() as "teacher" | "student")
    }
  }, [])

  return <></>
}
