File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import Image from 'next/image'
2+ import { Chess } from 'chess.ts'
3+ import toast from 'react-hot-toast'
24import { useRouter } from 'next/router'
35import { AnimatePresence } from 'framer-motion'
46import { useCallback , useContext , useState } from 'react'
@@ -97,10 +99,15 @@ export const PlaySetupModal: React.FC<Props> = (props: Props) => {
9799
98100 const start = useCallback (
99101 ( color : Color | undefined ) => {
100- setPlaySetupModalProps ( undefined )
101-
102102 const player = color ?? [ 'white' , 'black' ] [ Math . floor ( Math . random ( ) * 2 ) ]
103103
104+ if ( fen && ! new Chess ( ) . validateFen ( fen ) . valid ) {
105+ toast . error ( 'Invalid Starting FEN provided' )
106+ return
107+ }
108+
109+ setPlaySetupModalProps ( undefined )
110+
104111 if ( props . playType == 'againstMaia' ) {
105112 push ( {
106113 pathname : '/play/maia' ,
You can’t perform that action at this time.
0 commit comments