import React, { useRef } from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { GameProvider } from './contexts/GameContext';
import { GameBoard } from './components/GameBoard';

const queryClient = new QueryClient();

const MineSeeker = ({ env, gameId }) => {
  const isEnvDev = 'dev' === env;
  const gameAssoc = useRef('' !== gameId ? gameId : crypto.randomUUID()).current;
  const gameInherited = '' !== gameId;

  return (
    <QueryClientProvider client={queryClient}>
      <GameProvider>
        <GameBoard
          gameAssoc={gameAssoc}
          gameInherited={gameInherited}
          isEnvDev={isEnvDev}
        />
      </GameProvider>
    </QueryClientProvider>
  );
};

export default MineSeeker;
