import { useGameItems } from "@/context/GameItemsContext";
import { Layout } from "antd";
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import Player from "./Lobby/Player";
import SlotList from "./Lobby/SlotList";

const Lobby = () => {
	const { player, setPlayer } = useGameItems();
	const navigate = useNavigate();
	const { token } = player;

	function onLoad() {
		if (!token) {
			navigate(`/`);
			return;
		}
	}

	useEffect(() => {
		onLoad();
	}, []);

	return (
		<Layout hasSider style={{ height: "100%", position: "relative" }}>
			<Player />
			{<SlotList />}
		</Layout>
	);
};

export default Lobby;