Skip to content

Commit 0d7fe11

Browse files
Feat para assignment css (#254)
* Add duration assigment step and create task on save Closes #238. * Fix type issues * added tests for iep.getSubgoal and iep.assignTaskToParas * added some brute force css on buttons and benchmarks as placeholders for MUI themes for primary and secondary buttons and comments on future fixes * made Next button disabled unless at least one Staff member is selected and fixed "focus" state of "Save" button to unfocused until selected --------- Co-authored-by: Max Isom <hi@maxisom.me>
1 parent 40d75bd commit 0d7fe11

File tree

2 files changed

+91
-57
lines changed

2 files changed

+91
-57
lines changed

src/components/subgoal/Subgoal-Assignment-Modal.tsx

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import {
1313
DialogContent,
1414
DialogActions,
1515
} from "@mui/material";
16-
import { useState } from "react";
16+
import { useState, useRef } from "react";
1717
import $subgoal from "./Subgoal-Assignment-Modal.module.css";
18+
1819
import {
1920
AssignmentDuration,
2021
DurationSelectionStep,
@@ -41,6 +42,7 @@ type Step = (typeof STEPS)[number];
4142

4243
export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
4344
const [selectedParaIds, setSelectedParaIds] = useState<string[]>([]);
45+
const nextButtonRef = useRef<HTMLButtonElement>(null);
4446
const [assignmentDuration, setAssignmentDuration] =
4547
useState<AssignmentDuration>({ type: "forever" });
4648
const [currentModalSelection, setCurrentModalSelection] =
@@ -77,6 +79,9 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
7779
};
7880

7981
const handleNext = async () => {
82+
if (nextButtonRef.current) {
83+
nextButtonRef.current.blur();
84+
}
8085
const currentStepIndex = STEPS.indexOf(currentModalSelection);
8186
const nextStep = STEPS[currentStepIndex + 1];
8287
if (nextStep) {
@@ -123,7 +128,6 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
123128
</p>
124129
))}
125130
</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 */}
127131
{currentModalSelection === "PARA_SELECTION" && (
128132
<Box>
129133
<p>Select one or more paras:</p>
@@ -136,11 +140,11 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
136140
borderRadius: 1,
137141
}}
138142
>
143+
{/* Design ask is to reorder the mapped staff so that the selected staff are moved to the top of the list */}
139144
<List sx={{ p: 0 }} className={$subgoal.staffListItemText}>
140145
{myParas
141146
?.filter((para): para is ParaProps => para !== undefined)
142147
.map((para) => (
143-
// CSS ask is to reorder the mapped staff so that the selected staff are moved to the top of the list
144148
<ListItem key={para.user_id} sx={{ px: 0, py: 0 }}>
145149
<ListItemButton
146150
dense
@@ -164,7 +168,6 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
164168
</Box>
165169
</Box>
166170
)}
167-
{/* Enter 2nd selection process here, utilizing selected staff at the end of the process */}
168171
{currentModalSelection === "DURATION_SELECTION" && (
169172
<Box>
170173
<DurationSelectionStep
@@ -177,21 +180,61 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
177180
<DialogActions>
178181
{currentModalSelection !== STEPS[0] && (
179182
<Button
180-
variant="contained"
183+
variant="outlined"
181184
className={$subgoal.button}
182185
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+
}}
184203
disabled={assignTaskToPara.isLoading}
185204
>
186205
Back
187206
</Button>
188207
)}
189-
208+
{/* we should have reusable variables/classNames for all of this sx:CSS once the global themes are resolved */}
190209
<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+
}}
191232
variant="contained"
192-
className={$subgoal.button}
193233
onClick={handleNext}
194-
disabled={assignTaskToPara.isLoading}
234+
ref={nextButtonRef}
235+
disabled={
236+
assignTaskToPara.isLoading || selectedParaIds.length === 0
237+
}
195238
>
196239
{currentModalSelection === STEPS[STEPS.length - 1]
197240
? "Save"

src/components/subgoal/Subgoal.tsx

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,72 +11,63 @@ interface SubgoalProps {
1111

1212
const Subgoals = ({ subgoal }: SubgoalProps) => {
1313
const [isAssignmentModalOpen, setIsAssignmentModalOpen] = useState(false);
14-
const task = trpc.iep.tempAddTaskToSelf.useMutation();
15-
16-
const assignToPara = async () => {
17-
const result = await task.mutateAsync({
18-
subgoal_id: subgoal.subgoal_id,
19-
due_date: new Date(2023, 8, 20),
20-
trial_count: 5,
21-
});
22-
if (!result) {
23-
alert("Error: Benchmark already assigned to self.");
24-
} else {
25-
alert("Success! Benchmark assigned to self.");
26-
}
27-
};
2814

2915
return (
30-
<>
16+
<Box sx={{ border: "1px solid #B9C1C6" }}>
3117
<Box
3218
sx={{
33-
display: "flex",
19+
display: "flex-col",
3420
justifyContent: "space-between",
35-
backgroundColor: "#f4d5d5",
21+
backgroundColor: "#fff",
3622
padding: "1rem",
3723
}}
3824
>
3925
<p>{subgoal.description}</p>
40-
<Button
41-
sx={{
42-
height: "24px",
43-
width: "auto",
44-
padding: "0px 20px",
45-
backgroundColor: "#5347d7",
46-
borderRadius: "5px",
47-
border: "none",
48-
color: "#ffffff",
49-
fontFamily: "Quicksand",
50-
}}
51-
variant="contained"
52-
onClick={assignToPara}
53-
>
54-
Assign
55-
</Button>
56-
57-
<Button
26+
<Box
5827
sx={{
59-
height: "24px",
60-
width: "auto",
61-
padding: "0px 20px",
62-
backgroundColor: "#5347d7",
63-
borderRadius: "5px",
64-
border: "none",
65-
color: "#ffffff",
66-
fontFamily: "Quicksand",
28+
display: "flex",
29+
justifyContent: "space-between",
6730
}}
68-
variant="contained"
69-
onClick={() => setIsAssignmentModalOpen(true)}
7031
>
71-
[Draft] Assign
72-
</Button>
32+
<p> BASELINE</p>
33+
<p> CURRENT</p>
34+
<Box
35+
sx={{
36+
display: "flex-col",
37+
}}
38+
>
39+
<p>STAFF</p>
40+
<Button
41+
sx={{
42+
height: "24px",
43+
flex: "flex-end",
44+
width: "auto",
45+
padding: "20px 10px",
46+
backgroundColor: "#fff ",
47+
borderWidth: "1px",
48+
borderColor: "#20159E",
49+
borderRadius: "8px",
50+
color: "#20159E",
51+
fontFamily: "Quicksand",
52+
textTransform: "none",
53+
"&:hover": {
54+
backgroundColor: "#F6F5FF",
55+
},
56+
}}
57+
variant="outlined"
58+
onClick={() => setIsAssignmentModalOpen(true)}
59+
>
60+
Assign Staff
61+
</Button>
62+
</Box>
63+
</Box>
7364
</Box>
7465
<SubgoalAssignmentModal
7566
isOpen={isAssignmentModalOpen}
7667
onClose={() => setIsAssignmentModalOpen(false)}
7768
subgoal_id={subgoal.subgoal_id}
7869
/>
79-
</>
70+
</Box>
8071
);
8172
};
8273

0 commit comments

Comments
 (0)