@@ -5,11 +5,11 @@ import { BarLoader } from 'react-spinners';
55import { Button , Container , NoteBox } from '@/components' ;
66import { useCompetitionRemoteControl } from '@/hooks/useCompetitionRemoteControl' ;
77import { getRooms } from '@/lib/activities' ;
8- import { RemoteActivityGroup , RemoteActivityState } from '@/lib/notifyCompRemoteActivities' ;
8+ import { RemoteActivityState } from '@/lib/notifyCompRemoteActivities' ;
99import { useNotifyCompRemoteAuth } from '@/providers/NotifyCompRemoteAuthProvider' ;
1010import { useWCIF } from '@/providers/WCIFProvider' ;
1111import { RemoteAction , RemoteActionDialog } from './RemoteActionDialog' ;
12- import { RemoteActivityList , RemoteGroupList } from './RemoteActivityList' ;
12+ import { RemoteActivityList } from './RemoteActivityList' ;
1313
1414const confirmAction = ( message : string ) => window . confirm ( message ) ;
1515
@@ -24,15 +24,15 @@ export default function CompetitionRemote() {
2424 const { competitionId } = useParams < { competitionId : string } > ( ) ;
2525 const { wcif, setTitle } = useWCIF ( ) ;
2626 const remoteAuth = useNotifyCompRemoteAuth ( ) ;
27- const [ selectedRoomId , setSelectedRoomId ] = useState < number | 'all' > ( 'all' ) ;
27+ const [ selectedRoomId , setSelectedRoomId ] = useState < number | null > ( null ) ;
2828 const [ pendingAction , setPendingAction ] = useState < PendingRemoteAction | null > ( null ) ;
2929
3030 useEffect ( ( ) => {
3131 setTitle ( 'Remote' ) ;
3232 } , [ setTitle ] ) ;
3333
3434 const rooms = useMemo ( ( ) => ( wcif ? getRooms ( wcif ) : [ ] ) , [ wcif ] ) ;
35- const roomId = selectedRoomId === 'all' ? undefined : selectedRoomId ;
35+ const roomId = selectedRoomId ?? rooms [ 0 ] ?. id ;
3636 const remote = useCompetitionRemoteControl ( {
3737 competitionId : competitionId || '' ,
3838 roomId,
@@ -64,29 +64,6 @@ export default function CompetitionRemote() {
6464 } ) ;
6565 } ;
6666
67- const selectGroup = ( group : RemoteActivityGroup ) => {
68- if ( group . status === 'done' ) {
69- return ;
70- }
71-
72- const action = group . status === 'current' || group . status === 'mixed' ? 'stop' : 'start' ;
73- const roomNames = [ ...new Set ( group . scheduledActivities . map ( ( activity ) => activity . room . name ) ) ] ;
74-
75- setPendingAction ( {
76- action,
77- activityName : group . name ,
78- onConfirm : ( ) => {
79- if ( action === 'start' ) {
80- void remote . startGroup ( group ) ;
81- return ;
82- }
83-
84- void remote . stopGroup ( group ) ;
85- } ,
86- roomNames,
87- } ) ;
88- } ;
89-
9067 return (
9168 < Container className = "px-4 py-8" >
9269 < div className = "space-y-6" >
@@ -130,23 +107,17 @@ export default function CompetitionRemote() {
130107 < div className = "space-y-4" >
131108 < div className = "flex flex-col gap-4 md:flex-row md:items-end md:justify-between" >
132109 < div className = "flex flex-wrap gap-2" >
133- < label className = "flex flex-col gap-1 min-w-48 type-label" >
134- Room
135- < select
136- className = "select"
137- value = { selectedRoomId }
138- onChange = { ( event ) => {
139- const value = event . target . value ;
140- setSelectedRoomId ( value === 'all' ? 'all' : Number ( value ) ) ;
141- } } >
142- < option value = "all" > All rooms</ option >
143- { rooms . map ( ( room ) => (
144- < option key = { room . id } value = { room . id } >
145- { room . name }
146- </ option >
147- ) ) }
148- </ select >
149- </ label >
110+ < select
111+ aria-label = "Select remote room"
112+ className = "select min-w-48"
113+ value = { roomId ?? '' }
114+ onChange = { ( event ) => setSelectedRoomId ( Number ( event . target . value ) ) } >
115+ { rooms . map ( ( room ) => (
116+ < option key = { room . id } value = { room . id } >
117+ { room . name }
118+ </ option >
119+ ) ) }
120+ </ select >
150121 </ div >
151122 < Button
152123 type = "button"
@@ -169,19 +140,11 @@ export default function CompetitionRemote() {
169140 className = { classNames ( 'space-y-4' , {
170141 'opacity-60' : remote . isSaving ,
171142 } ) } >
172- { selectedRoomId === 'all' ? (
173- < RemoteGroupList
174- disabled = { remote . isSaving }
175- groups = { remote . activityGroups }
176- onSelectGroup = { selectGroup }
177- />
178- ) : (
179- < RemoteActivityList
180- disabled = { remote . isSaving }
181- states = { remote . activityStates }
182- onSelectActivity = { selectActivity }
183- />
184- ) }
143+ < RemoteActivityList
144+ disabled = { remote . isSaving }
145+ states = { remote . activityStates }
146+ onSelectActivity = { selectActivity }
147+ />
185148 </ div >
186149 </ div >
187150 ) }
0 commit comments