File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -348,11 +348,7 @@ export const storeCustomGame = async (data: {
348348 pgn ?: string
349349 fen ?: string
350350} ) : Promise < {
351- id : string
352- name : string
353- pgn ?: string
354- fen ?: string
355- created_at : string
351+ game_id : string
356352} > => {
357353 const res = await fetch ( buildUrl ( 'analysis/store_custom_game' ) , {
358354 method : 'POST' ,
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
1313 fetchAnalyzedPgnGame ,
1414 fetchAnalyzedWorldChampionshipGame ,
1515 retrieveGameAnalysisCache ,
16+ storeCustomGame ,
1617} from 'src/api'
1718import {
1819 AnalyzedGame ,
@@ -317,6 +318,21 @@ const Analysis: React.FC<Props> = ({
317318 setAnalysisEnabled ( ( prev ) => ! prev )
318319 } , [ ] )
319320
321+ const handleCustomAnalysis = useCallback (
322+ ( type : 'fen' | 'pgn' , data : string , name ?: string ) => {
323+ ; ( async ( ) => {
324+ const { game_id } = await storeCustomGame ( {
325+ name : name ,
326+ pgn : type === 'pgn' ? data : undefined ,
327+ fen : type === 'fen' ? data : undefined ,
328+ } )
329+
330+ router . push ( `/analysis/${ game_id } /custom` )
331+ } ) ( )
332+ } ,
333+ [ ] ,
334+ )
335+
320336 const handleLearnFromMistakes = useCallback ( ( ) => {
321337 controller . learnFromMistakes . start ( )
322338 setAnalysisEnabled ( false ) // Auto-disable analysis when starting learn mode
You can’t perform that action at this time.
0 commit comments