import { useState } from 'react'; import { Play, Trash2 } from 'lucide-react'; import { Badge } from './ui/badge'; import { Button } from './ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from './ui/card'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from './ui/dialog'; import type { PresetMeta } from '@shared/types'; import type { GameSummary } from '@shared/protocol'; interface Props { presets: PresetMeta[]; loading?: boolean; onPlay: (presetId: string) => void; /** Recent saved games (newest-updated first) for the "Saved games" section. */ savedGames?: GameSummary[]; /** The id remembered as the active game (drives the "Resume last game" button). */ activeGameId?: string | null; /** Resume a saved game by id (shared by the resume button and saved-games rows). */ onResume?: (id: string) => void; /** Delete a saved game by id (confirmed by a dialog in this component). */ onDelete?: (id: string) => void; } /** * Home screen: a grid of scenario cards (each with a Play button), a prominent * "Resume last game" affordance, and a "Saved games" section listing prior * games so the user can get back into one โ€” or delete it. */ export default function PresetPicker({ presets, loading, onPlay, savedGames = [], activeGameId, onResume, onDelete, }: Props) { const activeGame = activeGameId ? savedGames.find((g) => g.id === activeGameId) : undefined; // The game awaiting a delete confirmation (null = dialog closed). const [confirmDeleteId, setConfirmDeleteId] = useState(null); const confirmDeleteTarget = confirmDeleteId ? savedGames.find((g) => g.id === confirmDeleteId) : undefined; return (

History

An AI-driven alternate-history simulator. Pick a scenario and a nation, then shape the world turn by turn โ€” the LLM is the world engine.

{/* Resume last game โ€” prominent, shown whenever a game is remembered. */} {activeGameId && onResume && (
)}
{presets.map((p) => (
{p.title} {p.startDate}
{p.summary}
))}
{/* Saved games: get back into any prior game (or delete it). */} {savedGames.length > 0 && (

Saved games

{savedGames.map((g) => (
{g.presetTitle}
{g.date}
Turn {g.turn}
))}
)} {/* Confirm before permanently deleting a saved game. */} !o && setConfirmDeleteId(null)}> Delete this game? {confirmDeleteTarget ? `"${confirmDeleteTarget.presetTitle}" (turn ${confirmDeleteTarget.turn}, ${confirmDeleteTarget.date}) will be permanently removed. This cannot be undone.` : 'This game will be permanently removed.'}
); }