import * as React from 'react'; import { playSound } from '../services/soundService'; interface PromotionDialogProps { isOpen: boolean; position: { x: number; y: number }; color: 'white' | 'black'; onSelect: (piece: string) => void; onCancel: () => void; } const PromotionDialog: React.FC = ({ isOpen, position, color, onSelect, onCancel }) => { if (!isOpen) return null; const pieces = ['queen', 'rook', 'bishop', 'knight']; const handleSelect = (piece: string) => { playSound('promote'); onSelect(piece); }; // Position the dialog near the promotion square const style: React.CSSProperties = { position: 'absolute', left: `${position.x}px`, top: `${position.y}px`, transform: 'translate(-50%, -50%)', zIndex: 1000 }; return (
e.stopPropagation()} >

Promote to

{pieces.map((piece) => (
handleSelect(piece)} >
))}
); }; export default PromotionDialog;