import { useState } from "react"; import { useGameStore } from "@/managers/stores/useGameStore"; export function IntroUI(): React.JSX.Element | null { const step = useGameStore((state) => state.intro.currentStep); const setPlayerName = useGameStore((state) => state.setPlayerName); const setStep = useGameStore((state) => state.setIntroStep); const [inputValue, setInputValue] = useState(""); if (step !== "naming") return null; const handleSubmit = (): void => { if (inputValue.trim() === "") return; setPlayerName(inputValue.trim()); setStep("bienvenue"); }; const handleKeyDown = (e: React.KeyboardEvent): void => { if (e.key === "Enter") { handleSubmit(); } }; return (
Bienvenue {playerName} !