import "../style/theme/default.css" import "../style/new_tactic_panel.css" import plainCourt from "../assets/court/full_court.svg" import halfCourt from "../assets/court/half_court.svg" import { CourtType } from "../model/tactic/Tactic.ts" import { startTransition, useCallback } from "react" import { fetchAPI } from "../Fetcher.ts" import { getSession } from "../api/session.ts" import { useNavigate } from "react-router-dom" export const DEFAULT_TACTIC_NAME = "Nouvelle tactique" export default function NewTacticPage() { return (

Selectionnez un terrain

) } function CourtKindButton({ name, image, courtType, }: { name: string image: string courtType: CourtType }) { const navigate = useNavigate() return (
{ // if user is not authenticated if (!getSession().auth) { startTransition(() => { navigate(`/tactic/edit-guest`) }) } const response = await fetchAPI( "tactics", { name: DEFAULT_TACTIC_NAME, courtType, }, "POST", ) if (response.status === 401) startTransition(() => { // if unauthorized navigate("/login") return }) const { id } = await response.json() startTransition(() => { navigate(`/tactic/${id}/edit`) }) }, [courtType, navigate])}>
{name}

{name}

) }