@@ -13,8 +13,9 @@ import {
13
13
DialogContent ,
14
14
DialogActions ,
15
15
} from "@mui/material" ;
16
- import { useState } from "react" ;
16
+ import { useState , useRef } from "react" ;
17
17
import $subgoal from "./Subgoal-Assignment-Modal.module.css" ;
18
+
18
19
import {
19
20
AssignmentDuration ,
20
21
DurationSelectionStep ,
@@ -41,6 +42,7 @@ type Step = (typeof STEPS)[number];
41
42
42
43
export const SubgoalAssignmentModal = ( props : SubgoalAssignmentModalProps ) => {
43
44
const [ selectedParaIds , setSelectedParaIds ] = useState < string [ ] > ( [ ] ) ;
45
+ const nextButtonRef = useRef < HTMLButtonElement > ( null ) ;
44
46
const [ assignmentDuration , setAssignmentDuration ] =
45
47
useState < AssignmentDuration > ( { type : "forever" } ) ;
46
48
const [ currentModalSelection , setCurrentModalSelection ] =
@@ -77,6 +79,9 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
77
79
} ;
78
80
79
81
const handleNext = async ( ) => {
82
+ if ( nextButtonRef . current ) {
83
+ nextButtonRef . current . blur ( ) ;
84
+ }
80
85
const currentStepIndex = STEPS . indexOf ( currentModalSelection ) ;
81
86
const nextStep = STEPS [ currentStepIndex + 1 ] ;
82
87
if ( nextStep ) {
@@ -123,7 +128,6 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
123
128
</ p >
124
129
) ) }
125
130
</ Box >
126
- { /* we could make this and the 2nd selection process with a reusable component, e.g. labels in the <p> below could be from rendering {selectionLabel} but this is one solution to start */ }
127
131
{ currentModalSelection === "PARA_SELECTION" && (
128
132
< Box >
129
133
< p > Select one or more paras:</ p >
@@ -136,11 +140,11 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
136
140
borderRadius : 1 ,
137
141
} }
138
142
>
143
+ { /* Design ask is to reorder the mapped staff so that the selected staff are moved to the top of the list */ }
139
144
< List sx = { { p : 0 } } className = { $subgoal . staffListItemText } >
140
145
{ myParas
141
146
?. filter ( ( para ) : para is ParaProps => para !== undefined )
142
147
. map ( ( para ) => (
143
- // CSS ask is to reorder the mapped staff so that the selected staff are moved to the top of the list
144
148
< ListItem key = { para . user_id } sx = { { px : 0 , py : 0 } } >
145
149
< ListItemButton
146
150
dense
@@ -164,7 +168,6 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
164
168
</ Box >
165
169
</ Box >
166
170
) }
167
- { /* Enter 2nd selection process here, utilizing selected staff at the end of the process */ }
168
171
{ currentModalSelection === "DURATION_SELECTION" && (
169
172
< Box >
170
173
< DurationSelectionStep
@@ -177,21 +180,61 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
177
180
< DialogActions >
178
181
{ currentModalSelection !== STEPS [ 0 ] && (
179
182
< Button
180
- variant = "contained "
183
+ variant = "outlined "
181
184
className = { $subgoal . button }
182
185
onClick = { handleBack }
183
- sx = { { mr : "auto" } }
186
+ sx = { {
187
+ mr : "auto" ,
188
+ height : "24px" ,
189
+ flex : "flex-end" ,
190
+ width : "auto" ,
191
+ padding : "20px 10px" ,
192
+ backgroundColor : "#fff " ,
193
+ borderWidth : "1px" ,
194
+ borderColor : "#20159E" ,
195
+ borderRadius : "8px" ,
196
+ color : "#20159E" ,
197
+ fontFamily : "Quicksand" ,
198
+ textTransform : "none" ,
199
+ "&:hover" : {
200
+ backgroundColor : "#F6F5FF" ,
201
+ } ,
202
+ } }
184
203
disabled = { assignTaskToPara . isLoading }
185
204
>
186
205
Back
187
206
</ Button >
188
207
) }
189
-
208
+ { /* we should have reusable variables/classNames for all of this sx:CSS once the global themes are resolved */ }
190
209
< Button
210
+ sx = { {
211
+ height : "24px" ,
212
+ flex : "flex-end" ,
213
+ width : "auto" ,
214
+ padding : "20px 10px" ,
215
+ backgroundColor : "#20159E " ,
216
+ borderRadius : "8px" ,
217
+ color : "#FFFFFF" ,
218
+ fontFamily : "Quicksand" ,
219
+ textTransform : "none" ,
220
+ boxShadow : "none" ,
221
+ "&:hover" : {
222
+ backgroundColor : "#20159E " ,
223
+ boxShadow : "0px 1px 3px 1px rgba(0, 0, 0, .30)" ,
224
+ } ,
225
+ "&:focus" : {
226
+ backgroundColor : "#5347D7" ,
227
+ } ,
228
+ "&:active" : {
229
+ backgroundColor : "#140B7A" ,
230
+ } ,
231
+ } }
191
232
variant = "contained"
192
- className = { $subgoal . button }
193
233
onClick = { handleNext }
194
- disabled = { assignTaskToPara . isLoading }
234
+ ref = { nextButtonRef }
235
+ disabled = {
236
+ assignTaskToPara . isLoading || selectedParaIds . length === 0
237
+ }
195
238
>
196
239
{ currentModalSelection === STEPS [ STEPS . length - 1 ]
197
240
? "Save"
0 commit comments