import { useState } from "react"; import { useGameStore } from "@/managers/stores/useGameStore"; export function IntroUI(): React.JSX.Element | null { const step = useGameStore((state) => state.missionFlow.step); const setPlayerName = useGameStore((state) => state.setPlayerName); const setStep = useGameStore((state) => state.setFlowStep); const [inputValue, setInputValue] = useState(""); if (step !== "naming") return null; const handleSubmit = (): void => { if (inputValue.trim() === "") return; console.log("[IntroUI] Submitting, name:", inputValue.trim()); setPlayerName(inputValue.trim()); console.log("[IntroUI] Calling transitionTo('bienvenue')"); setStep("bienvenue"); console.log("[IntroUI] After transitionTo, step should be:", step); }; const handleKeyDown = (e: React.KeyboardEvent): void => { if (e.key === "Enter") { handleSubmit(); } }; return (

Quel est votre prénom ?

setInputValue(e.target.value)} onKeyDown={handleKeyDown} placeholder="Votre prénom" autoFocus style={{ padding: "0.75rem", fontSize: "1rem", borderRadius: "6px", border: "1px solid #444", backgroundColor: "#2a2a2a", color: "#fff", outline: "none", }} />
); } export function BienvenueDisplay(): React.JSX.Element | null { const step = useGameStore((state) => state.missionFlow.step); const playerName = useGameStore((state) => state.missionFlow.playerName); if (step !== "bienvenue") return null; return (

Bienvenue {playerName} !

); }