1+ import { hasDistributedAttempts , parseActivityCode } from '../lib/domain/activities' ;
12import { type ActivityWithParent } from '../lib/domain/types' ;
2- import { Recipes } from '../lib/recipes ' ;
3+ import Box from '@mui/material/Box ' ;
34import Button from '@mui/material/Button' ;
4- import MenuItem from '@mui/material/MenuItem' ;
5- import Select from '@mui/material/Select' ;
6- import FormControl from '@mui/material/FormControl' ;
7- import InputLabel from '@mui/material/InputLabel' ;
85import { type Person } from '@wca/helpers' ;
96
107interface RoundActionButtonsProps {
@@ -14,14 +11,14 @@ interface RoundActionButtonsProps {
1411 activityCode : string ;
1512 onConfigureAssignments : ( ) => void ;
1613 onGenerateAssignments : ( ) => void ;
17- recipeId : string ;
18- onChangeRecipeId : ( recipeId : string ) => void ;
19- onRunRecipe : ( ) => void ;
14+ onAssignToRoundAttempt : ( ) => void ;
15+ onResetAttemptAssignments : ( ) => void ;
2016 onConfigureStationNumbers : ( activityCode : string ) => void ;
2117 onConfigureGroups : ( ) => void ;
2218 onResetAll : ( ) => void ;
2319 onResetNonScrambling : ( ) => void ;
2420 onConfigureGroupCounts : ( ) => void ;
21+ isDistributedAttemptRoundLevel : boolean ;
2522}
2623
2724export const RoundActionButtons = ( {
@@ -31,15 +28,52 @@ export const RoundActionButtons = ({
3128 activityCode,
3229 onConfigureAssignments,
3330 onGenerateAssignments,
34- recipeId,
35- onChangeRecipeId,
36- onRunRecipe,
31+ onAssignToRoundAttempt,
32+ onResetAttemptAssignments,
3733 onConfigureStationNumbers,
3834 onConfigureGroups,
3935 onResetAll,
4036 onResetNonScrambling,
4137 onConfigureGroupCounts,
38+ isDistributedAttemptRoundLevel,
4239} : RoundActionButtonsProps ) => {
40+ const { attemptNumber } = parseActivityCode ( activityCode ) ;
41+ const isAttemptActivity = hasDistributedAttempts ( activityCode ) && attemptNumber !== undefined ;
42+
43+ if ( isDistributedAttemptRoundLevel ) {
44+ return (
45+ < >
46+ < Button onClick = { onConfigureAssignments } > Configure Round Attempt Assignments</ Button >
47+ < Button onClick = { onAssignToRoundAttempt } > Assign All</ Button >
48+ < Box sx = { { display : 'flex' , flex : 1 } } />
49+ < Button color = "error" onClick = { onResetAttemptAssignments } >
50+ Clear Round Attempt Assignments
51+ </ Button >
52+ </ >
53+ ) ;
54+ }
55+
56+ if ( groups . length === 0 && isAttemptActivity ) {
57+ if ( personsAssignedToCompete . length > 0 ) {
58+ return (
59+ < >
60+ < Button onClick = { onAssignToRoundAttempt } > Assign to Round Attempt</ Button >
61+ < Box sx = { { display : 'flex' , flex : 1 } } />
62+ < Button color = "error" onClick = { onResetAttemptAssignments } >
63+ Reset Attempt Assignments
64+ </ Button >
65+ </ >
66+ ) ;
67+ }
68+
69+ return (
70+ < >
71+ < Button onClick = { onAssignToRoundAttempt } > Assign to Round Attempt</ Button >
72+ < Button onClick = { onConfigureGroupCounts } > Configure Group Counts</ Button >
73+ </ >
74+ ) ;
75+ }
76+
4377 if ( groups . length === 0 ) {
4478 return (
4579 < >
@@ -53,22 +87,6 @@ export const RoundActionButtons = ({
5387 < >
5488 < Button onClick = { onConfigureAssignments } > Configure Assignments</ Button >
5589 < Button onClick = { onGenerateAssignments } > Assign Competitor and Judging Assignments</ Button >
56- < FormControl size = "small" sx = { { minWidth : 220 , marginLeft : 2 } } >
57- < InputLabel id = "recipe-select-label" > Recipe</ InputLabel >
58- < Select
59- labelId = "recipe-select-label"
60- label = "Recipe"
61- value = { recipeId }
62- onChange = { ( e ) => onChangeRecipeId ( String ( e . target . value ) ) }
63- >
64- { Recipes . map ( ( r ) => (
65- < MenuItem key = { r . id } value = { r . id } >
66- { r . name }
67- </ MenuItem >
68- ) ) }
69- </ Select >
70- </ FormControl >
71- < Button onClick = { onRunRecipe } > Run Recipe</ Button >
7290 < div style = { { display : 'flex' , flex : 1 } } />
7391 < Button onClick = { onConfigureGroups } > Configure Groups</ Button >
7492 < Button color = "error" onClick = { onResetAll } >
0 commit comments