import { PropsWithChildren } from "react";
import { Button } from "../ui/button";
import { useResetAtom } from "jotai/utils";
import { boardAtom } from "@/lib/state";

export function NewGameButton(props: PropsWithChildren) {
  const newGame = useNewGameButton();

  return <Button {...props} onClick={() => newGame()} size={"lg"} />;
}

function useNewGameButton() {
  return useResetAtom(boardAtom);
}
