1- import { type ActivityWithParent } from '../lib/domain/types' ;
21import { Recipes } from '../lib/recipes' ;
2+ import { hasDistributedAttempts , parseActivityCode } from '../lib/domain/activities' ;
3+ import { type ActivityWithParent } from '../lib/domain/types' ;
4+ import Box from '@mui/material/Box' ;
35import Button from '@mui/material/Button' ;
4- import MenuItem from '@mui/material/MenuItem' ;
5- import Select from '@mui/material/Select' ;
66import FormControl from '@mui/material/FormControl' ;
77import InputLabel from '@mui/material/InputLabel' ;
8+ import MenuItem from '@mui/material/MenuItem' ;
9+ import Select from '@mui/material/Select' ;
810import { type Person } from '@wca/helpers' ;
911
1012interface RoundActionButtonsProps {
@@ -16,11 +18,14 @@ interface RoundActionButtonsProps {
1618 recipeId : string ;
1719 onChangeRecipeId : ( recipeId : string ) => void ;
1820 onRunRecipe : ( ) => void ;
21+ onAssignToRoundAttempt : ( ) => void ;
22+ onResetAttemptAssignments : ( ) => void ;
1923 onConfigureStationNumbers : ( activityCode : string ) => void ;
2024 onConfigureGroups : ( ) => void ;
2125 onResetAll : ( ) => void ;
2226 onResetNonScrambling : ( ) => void ;
2327 onConfigureGroupCounts : ( ) => void ;
28+ isDistributedAttemptRoundLevel : boolean ;
2429}
2530
2631export const RoundActionButtons = ( {
@@ -32,12 +37,52 @@ export const RoundActionButtons = ({
3237 recipeId,
3338 onChangeRecipeId,
3439 onRunRecipe,
40+ onAssignToRoundAttempt,
41+ onResetAttemptAssignments,
3542 onConfigureStationNumbers,
3643 onConfigureGroups,
3744 onResetAll,
3845 onResetNonScrambling,
3946 onConfigureGroupCounts,
47+ isDistributedAttemptRoundLevel,
4048} : RoundActionButtonsProps ) => {
49+ const { attemptNumber } = parseActivityCode ( activityCode ) ;
50+ const isAttemptActivity = hasDistributedAttempts ( activityCode ) && attemptNumber !== undefined ;
51+
52+ if ( isDistributedAttemptRoundLevel ) {
53+ return (
54+ < >
55+ < Button onClick = { onConfigureAssignments } > Configure Round Attempt Assignments</ Button >
56+ < Button onClick = { onAssignToRoundAttempt } > Assign All</ Button >
57+ < Box sx = { { display : 'flex' , flex : 1 } } />
58+ < Button color = "error" onClick = { onResetAttemptAssignments } >
59+ Clear Round Attempt Assignments
60+ </ Button >
61+ </ >
62+ ) ;
63+ }
64+
65+ if ( groups . length === 0 && isAttemptActivity ) {
66+ if ( personsAssignedToCompete . length > 0 ) {
67+ return (
68+ < >
69+ < Button onClick = { onAssignToRoundAttempt } > Assign to Round Attempt</ Button >
70+ < Box sx = { { display : 'flex' , flex : 1 } } />
71+ < Button color = "error" onClick = { onResetAttemptAssignments } >
72+ Reset Attempt Assignments
73+ </ Button >
74+ </ >
75+ ) ;
76+ }
77+
78+ return (
79+ < >
80+ < Button onClick = { onAssignToRoundAttempt } > Assign to Round Attempt</ Button >
81+ < Button onClick = { onConfigureGroupCounts } > Configure Group Counts</ Button >
82+ </ >
83+ ) ;
84+ }
85+
4186 if ( groups . length === 0 ) {
4287 return (
4388 < >
@@ -56,8 +101,7 @@ export const RoundActionButtons = ({
56101 labelId = "recipe-select-label"
57102 label = "Recipe"
58103 value = { recipeId }
59- onChange = { ( e ) => onChangeRecipeId ( String ( e . target . value ) ) }
60- >
104+ onChange = { ( e ) => onChangeRecipeId ( String ( e . target . value ) ) } >
61105 { Recipes . map ( ( r ) => (
62106 < MenuItem key = { r . id } value = { r . id } >
63107 { r . name }
0 commit comments