"use client"; import React from "react"; import { Minus, RotateCcw, Trophy } from "lucide-react"; import { AnimatePresence, motion } from "motion/react"; import { Button } from "~/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "~/components/ui/dialog"; import { cn } from "~/lib/utils"; interface GameEndModalProps { open: boolean; winner: "white" | "black" | "draw" | null; reason?: string; whitePlayer?: string; blackPlayer?: string; onRematch: () => void; onClose: () => void; } /** * Game end modal with animations */ const GameEndModal: React.FC = ({ open, winner, reason = "Checkmate", whitePlayer = "White", blackPlayer = "Black", onRematch, onClose, }) => { const getTitle = () => { if (winner === "draw") return "Game Draw"; if (winner === "white") return `${whitePlayer} Wins!`; if (winner === "black") return `${blackPlayer} Wins!`; return "Game Over"; }; const getIcon = () => { if (winner === "draw") { return ( ); } return ( ); }; return (
{getIcon()}
{getTitle()} {reason}
{winner && (
Winner: {winner === "draw" ? "Draw" : winner}
Result: {winner === "white" ? "1-0" : winner === "black" ? "0-1" : "½-½"}
)}
); }; export { GameEndModal };