import { useState } from "react"; import type { CustomEvents, CustomGames, LaneId } from "../../shared/custom.ts"; import { useGameMeta } from "../state/gameMeta.tsx"; import type { EventDraft } from "../state/useCustom.ts"; import { EventForm, GameForm } from "./CustomForms.tsx"; /** * The reader's own games and events, in the settings panel (PRD F13). * * Their events are managed from the event itself — open it and the detail sheet * offers edit and delete, exactly where you would look for them. What has no * other home is the list of games they invented, and the way in to adding the * first event, so both live here. */ export function YourOwn({ games, events, lanes, onAddGame, onEditGame, onRemoveGame, onAddEvent, }: { games: CustomGames; events: CustomEvents; /** Every lane an event may be filed under, tracked games included. */ lanes: LaneId[]; onAddGame: (name: string, hue: string) => void; onEditGame: (id: string, name: string, hue: string) => void; onRemoveGame: (id: string) => { removed: boolean; blockedBy: number }; onAddEvent: (draft: EventDraft) => void; }) { const gameMeta = useGameMeta(); const [adding, setAdding] = useState<"game" | "event" | null>(null); const [editing, setEditing] = useState(null); const [refusal, setRefusal] = useState(null); const list = Object.values(games); return (

Your own games and events

Track something this app doesn't cover, or an event a source missed. Your dates are yours — they're never presented as coming from a wiki, and they travel in your export.

{list.length > 0 && (
    {list.map((game) => { const held = Object.values(events).filter( (e) => e.game === game.id, ).length; return (
  • {game.name} {held === 0 ? "no events yet" : `${held} event${held > 1 ? "s" : ""}`}
    {editing === game.id && ( { onEditGame(game.id, name, hue); setEditing(null); }} onCancel={() => setEditing(null)} /> )}
  • ); })}
)} {refusal !== null && (

{refusal}

)} {adding === "game" && ( { onAddGame(name, hue); setAdding(null); }} onCancel={() => setAdding(null)} /> )} {adding === "event" && ( { onAddEvent(draft); setAdding(null); }} onCancel={() => setAdding(null)} /> )} {adding === null && (
)}
); }