import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useNavigate } from "react-router"; import { useApi } from "../api/context"; import { PLAYER_STATE_KEY } from "../state/player"; /** First launch: create a guest account (decision: guests first, accounts later). */ export function StartScreen() { const api = useApi(); const queryClient = useQueryClient(); const navigate = useNavigate(); const start = useMutation({ mutationFn: () => api.call("createGuest", {}), onSuccess: ({ state }) => { // The session cookie is now set; the response already holds the new state. queryClient.setQueryData(PLAYER_STATE_KEY, state); // Straight to work: the first company run is one tap away (CR-001). void navigate("/contracts"); }, }); return (

DEADHEAD

Space Freight Tycoon

Fly company runs between Earth and the Moon, save up for your own ship, and build a freight empire across the solar system.

{start.isError && (

Could not start a company. Check your connection and try again.

)}
); }