import { useState } from 'react'; import type { GridMap } from '../types'; import './MapList.css'; interface Props { maps: GridMap[]; selectedMapId: string | null; onSelect: (id: string) => void; onCreate: (name: string) => void; onDelete: (id: string) => void; } export default function MapList({ maps, selectedMapId, onSelect, onCreate, onDelete }: Props) { const [newName, setNewName] = useState(''); function handleCreate(e: React.FormEvent) { e.preventDefault(); const name = newName.trim(); if (!name) return; onCreate(name); setNewName(''); } function handleDeleteClick(e: React.MouseEvent, id: string) { e.stopPropagation(); if (confirm('Delete this map? This cannot be undone.')) { onDelete(id); } } return ( ); }