11/* eslint-disable @next/next/no-img-element */
22/* eslint-disable jsx-a11y/alt-text */
3+ import { useState } from 'react'
34import { PieceSymbol } from 'chess.ts'
45
56import { BaseGame , Color } from 'src/types'
7+ import { ResignationConfirmModal } from 'src/components'
68
79const pieceTypes : PieceSymbol [ ] = [ 'k' , 'q' , 'r' , 'b' , 'n' , 'p' ]
810
@@ -52,6 +54,17 @@ export const HandBrainPlayControls: React.FC<Props> = ({
5254 simulateMaiaTime,
5355 setSimulateMaiaTime,
5456} : Props ) => {
57+ const [ showResignConfirm , setShowResignConfirm ] = useState ( false )
58+
59+ const handleResignClick = ( ) => {
60+ setShowResignConfirm ( true )
61+ }
62+
63+ const handleConfirmResign = ( ) => {
64+ if ( resign ) {
65+ resign ( )
66+ }
67+ }
5568 const status = playerActive
5669 ? isBrain
5770 ? selectedPiece
@@ -218,7 +231,7 @@ export const HandBrainPlayControls: React.FC<Props> = ({
218231 { /* Resign Button - Smaller and Less Prominent */ }
219232 < div className = "flex justify-center" >
220233 < button
221- onClick = { resign }
234+ onClick = { handleResignClick }
222235 disabled = { ! resign || ! playerActive }
223236 className = { `rounded px-3 py-1 text-xs font-medium transition-colors duration-200 ${
224237 resign && playerActive
@@ -234,6 +247,12 @@ export const HandBrainPlayControls: React.FC<Props> = ({
234247 </ >
235248 ) }
236249 </ div >
250+
251+ < ResignationConfirmModal
252+ isOpen = { showResignConfirm }
253+ onClose = { ( ) => setShowResignConfirm ( false ) }
254+ onConfirm = { handleConfirmResign }
255+ />
237256 </ div >
238257 )
239258}
0 commit comments