From df6e6499d30f06695e8ce69759232fb6c699efec Mon Sep 17 00:00:00 2001 From: Max Isom Date: Wed, 8 Nov 2023 19:12:41 -0800 Subject: [PATCH] Add para assignment dialog (#239) --- .../subgoal/Subgoal-Assignment-Modal.tsx | 91 +++++++++++++++++++ src/components/subgoal/Subgoal.tsx | 83 ++++++++++------- 2 files changed, 140 insertions(+), 34 deletions(-) create mode 100644 src/components/subgoal/Subgoal-Assignment-Modal.tsx diff --git a/src/components/subgoal/Subgoal-Assignment-Modal.tsx b/src/components/subgoal/Subgoal-Assignment-Modal.tsx new file mode 100644 index 00000000..b285caa8 --- /dev/null +++ b/src/components/subgoal/Subgoal-Assignment-Modal.tsx @@ -0,0 +1,91 @@ +import { trpc } from "@/client/lib/trpc"; +import { + Box, + Dialog, + DialogTitle, + Alert, + AlertTitle, + Button, + List, + ListItem, + ListItemButton, + ListItemIcon, + Checkbox, + ListItemText, +} from "@mui/material"; +import { useState } from "react"; + +interface SubgoalAssignmentModalProps { + isOpen: boolean; + onClose: () => void; +} + +export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => { + const [selectedParaIds, setSelectedParaIds] = useState([]); + const myParasQuery = trpc.case_manager.getMyParas.useQuery(); + + const handleParaToggle = (paraId: string) => () => { + setSelectedParaIds((prev) => { + if (prev.includes(paraId)) { + return prev.filter((id) => id !== paraId); + } else { + return [...prev, paraId]; + } + }); + }; + + const handleClose = () => { + props.onClose(); + setSelectedParaIds([]); + }; + + return ( + + Assign to benchmark + + + + Benchmark + By October, when given a list of 20 unfamiliar words that contain + short-vowel sounds, the student will correctly pronounce 18 of the 20 + words with 90% accuracy in 3 out of 4 trials. + + Select one or more paras: + + + {myParasQuery.data?.map((para) => ( + + + + + + + {para.first_name} {para.last_name} + + + + ))} + + + + + + + + ); +}; diff --git a/src/components/subgoal/Subgoal.tsx b/src/components/subgoal/Subgoal.tsx index 6ed72f41..a08222d6 100644 --- a/src/components/subgoal/Subgoal.tsx +++ b/src/components/subgoal/Subgoal.tsx @@ -2,25 +2,17 @@ import { trpc } from "@/client/lib/trpc"; import { Subgoal } from "@/types/global"; import Box from "@mui/material/Box"; import Button from "@mui/material/Button"; +import { useState } from "react"; +import { SubgoalAssignmentModal } from "./Subgoal-Assignment-Modal"; interface SubgoalProps { subgoal: Subgoal; } const Subgoals = ({ subgoal }: SubgoalProps) => { + const [isAssignmentModalOpen, setIsAssignmentModalOpen] = useState(false); const task = trpc.iep.tempAddTaskToSelf.useMutation(); - // TODO: add form to assign to my paras - // const assignToPara = (event: React.FormEvent) => { - // event.preventDefault(); - // const data = new FormData(event.currentTarget); - - // task.mutate({ - // subgoal_id: subgoal.subgoal_id, - // assignee_id: data.get("assignee_id") as string, - // due_date: new Date(data.get("due_date")) as Date - // }); - // } const assignToPara = async () => { const result = await task.mutateAsync({ subgoal_id: subgoal.subgoal_id, @@ -35,32 +27,55 @@ const Subgoals = ({ subgoal }: SubgoalProps) => { }; return ( - -

{subgoal.description}

- -
+

{subgoal.description}

+ + + + + setIsAssignmentModalOpen(false)} + /> + ); };