@@ -2,7 +2,6 @@ import React, { useState, useMemo, useEffect, useContext } from 'react'
22import Image from 'next/image'
33import { motion } from 'framer-motion'
44import Chessground from '@react-chess/chessground'
5- import { useWindowSize } from 'src/hooks/useWindowSize'
65import {
76 Opening ,
87 OpeningVariation ,
@@ -610,8 +609,6 @@ const SelectedPanel: React.FC<{
610609 activeTab : MobileTab
611610 selections : OpeningSelection [ ]
612611 removeSelection : ( id : string ) => void
613- drillCount : number
614- setDrillCount : ( count : number ) => void
615612 handleStartDrilling : ( ) => void
616613 selectedMaiaVersion : ( typeof MAIA_MODELS_WITH_NAMES ) [ 0 ]
617614 setSelectedMaiaVersion : ( version : ( typeof MAIA_MODELS_WITH_NAMES ) [ 0 ] ) => void
@@ -621,8 +618,6 @@ const SelectedPanel: React.FC<{
621618 activeTab,
622619 selections,
623620 removeSelection,
624- drillCount,
625- setDrillCount,
626621 handleStartDrilling,
627622 selectedMaiaVersion,
628623 setSelectedMaiaVersion,
@@ -752,38 +747,13 @@ const SelectedPanel: React.FC<{
752747 </ div >
753748 </ div >
754749
755- { /* Drill Count Configuration */ }
756- < div className = "mb-3 md:mb-4" >
757- < p className = "mb-1 text-xs font-medium md:mb-2 md:text-sm" >
758- Number of Drills: { drillCount }
759- </ p >
760- < input
761- type = "range"
762- min = "1"
763- max = "20"
764- value = { drillCount }
765- onChange = { ( e ) => setDrillCount ( parseInt ( e . target . value ) || 5 ) }
766- className = "w-full accent-human-4"
767- />
768- < div className = "mt-1 flex justify-between text-xs text-secondary" >
769- < span > 1</ span >
770- < span > 20</ span >
771- </ div >
772- < p className = "mt-1 text-xs text-secondary" >
773- { drillCount <= selections . length
774- ? `You'll play ${ drillCount } of your selected openings`
775- : selections . length > 0
776- ? `Each opening played at least once, with ${ drillCount - selections . length } repeats`
777- : 'Total number of opening drills to complete' }
778- </ p >
779- </ div >
780-
781750 < button
782751 onClick = { handleStartDrilling }
783752 disabled = { selections . length === 0 }
784753 className = "w-full rounded bg-human-4 py-2 text-sm font-medium transition-colors hover:bg-human-4/80 disabled:cursor-not-allowed disabled:opacity-50"
785754 >
786- Start Drilling ({ drillCount } drill{ drillCount !== 1 ? 's' : '' } )
755+ Start Drilling ({ selections . length } opening
756+ { selections . length !== 1 ? 's' : '' } )
787757 </ button >
788758 </ div >
789759 </ div >
@@ -807,7 +777,6 @@ export const OpeningSelectionModal: React.FC<Props> = ({
807777 )
808778 const [ selectedColor , setSelectedColor ] = useState < 'white' | 'black' > ( 'white' )
809779 const [ targetMoveNumber , setTargetMoveNumber ] = useState ( 10 )
810- const [ drillCount , setDrillCount ] = useState ( 5 )
811780 const [ searchTerm , setSearchTerm ] = useState ( '' )
812781 const [ activeTab , setActiveTab ] = useState < MobileTab > ( 'browse' )
813782 const [ initialTourCheck , setInitialTourCheck ] = useState ( false )
@@ -1022,57 +991,8 @@ export const OpeningSelectionModal: React.FC<Props> = ({
1022991 }
1023992 }
1024993
1025- // Helper function to generate drill sequenc
1026- const generateDrillSequence = (
1027- selections : OpeningSelection [ ] ,
1028- count : number ,
1029- ) : OpeningSelection [ ] => {
1030- if ( selections . length === 0 ) return [ ]
1031-
1032- const createUniqueDrill = (
1033- selection : OpeningSelection ,
1034- index : number ,
1035- ) : OpeningSelection => {
1036- const timestamp = Date . now ( )
1037- const uniqueId = `${ selection . id } -${ timestamp } -${ index } `
1038- return {
1039- ...selection ,
1040- id : uniqueId ,
1041- }
1042- }
1043-
1044- if ( count <= selections . length ) {
1045- const shuffled = [ ...selections ] . sort ( ( ) => Math . random ( ) - 0.5 )
1046- return shuffled
1047- . slice ( 0 , count )
1048- . map ( ( selection , index ) => createUniqueDrill ( selection , index ) )
1049- }
1050-
1051- // If drill count is more than selections, ensure each opening is played at least once
1052- const sequence : OpeningSelection [ ] = [ ]
1053-
1054- // Add each selection once
1055- selections . forEach ( ( selection , index ) => {
1056- sequence . push ( createUniqueDrill ( selection , index ) )
1057- } )
1058-
1059- const remaining = count - selections . length
1060-
1061- // Fill remaining slots by randomly picking from selections
1062- for ( let i = 0 ; i < remaining ; i ++ ) {
1063- const randomSelection =
1064- selections [ Math . floor ( Math . random ( ) * selections . length ) ]
1065- sequence . push ( createUniqueDrill ( randomSelection , selections . length + i ) )
1066- }
1067-
1068- // Shuffle the final sequence
1069- return sequence . sort ( ( ) => Math . random ( ) - 0.5 )
1070- }
1071-
1072994 const handleStartDrilling = async ( ) => {
1073995 if ( selections . length > 0 ) {
1074- const drillSequence = generateDrillSequence ( selections , drillCount )
1075-
1076996 try {
1077997 // Prepare API request data
1078998 const openings = selections . map ( ( selection ) => ( {
@@ -1087,13 +1007,11 @@ export const OpeningSelectionModal: React.FC<Props> = ({
10871007 openings,
10881008 opponent : selectedMaiaVersion . id ,
10891009 num_moves : targetMoveNumber ,
1090- num_drills : drillCount ,
1010+ num_drills : selections . length , // Use selections length instead of separate drill count
10911011 } )
10921012
10931013 const configuration : DrillConfiguration = {
10941014 selections,
1095- drillCount,
1096- drillSequence,
10971015 sessionId : response . session_id ,
10981016 }
10991017
@@ -1115,7 +1033,7 @@ export const OpeningSelectionModal: React.FC<Props> = ({
11151033
11161034 trackDrillConfigurationCompleted (
11171035 selections . length ,
1118- drillCount ,
1036+ selections . length , // Use selections length for drill count
11191037 uniqueOpenings ,
11201038 averageTargetMoves ,
11211039 maiaVersionsUsed ,
@@ -1128,8 +1046,6 @@ export const OpeningSelectionModal: React.FC<Props> = ({
11281046 // Still allow the drill to start even if API call fails
11291047 const configuration : DrillConfiguration = {
11301048 selections,
1131- drillCount,
1132- drillSequence,
11331049 }
11341050 onComplete ( configuration )
11351051 }
@@ -1219,8 +1135,6 @@ export const OpeningSelectionModal: React.FC<Props> = ({
12191135 activeTab = { activeTab }
12201136 selections = { selections }
12211137 removeSelection = { removeSelection }
1222- drillCount = { drillCount }
1223- setDrillCount = { setDrillCount }
12241138 handleStartDrilling = { handleStartDrilling }
12251139 selectedMaiaVersion = { selectedMaiaVersion }
12261140 setSelectedMaiaVersion = { setSelectedMaiaVersion }
0 commit comments