Skip to content

Commit

Permalink
initiated conditional setting for changing between the first and seco…
Browse files Browse the repository at this point in the history
…nd modal selection procecsses.
  • Loading branch information
tessathornberry committed Nov 10, 2023
1 parent c6f707f commit 5d97320
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 35 deletions.
2 changes: 2 additions & 0 deletions src/components/subgoal/Subgoal-Assignment-Modal.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.assignSubgoalModal {
max-width: 360px;
width: 360px;
max-height: 580px;
height: 800px;
margin: auto;
font-size: 16px;
text-align: left;
Expand Down
79 changes: 44 additions & 35 deletions src/components/subgoal/Subgoal-Assignment-Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {
Box,
Dialog,
DialogTitle,
Alert,
AlertTitle,
Button,
List,
ListItem,
Expand All @@ -24,6 +22,7 @@ interface SubgoalAssignmentModalProps {

export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
const [selectedParaIds, setSelectedParaIds] = useState<string[]>([]);
const [currentModalSelection, setCurrentModalSelection] = useState(1);
const myParasQuery = trpc.case_manager.getMyParas.useQuery();
const { data: subgoal } = trpc.iep.getSubgoal.useQuery({
subgoal_id: props.subgoal_id,
Expand All @@ -39,10 +38,10 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
});
};

//onClose, keep data in state? or have notification to verify navigation away from page.
const handleClose = () => {
props.onClose();
setSelectedParaIds([]);
setCurrentModalSelection(1);
};

return (
Expand All @@ -67,41 +66,51 @@ export const SubgoalAssignmentModal = (props: SubgoalAssignmentModalProps) => {
</p>
))}
</Box>
<p>Select one or more paras:</p>
<Box
sx={{
my: 2,
maxHeight: "10rem",
overflow: "auto",
border: "1px solid #d6dde1",
borderRadius: 1,
}}
>
<List sx={{ p: 0 }} className={$subgoal.staffListItemText}>
{myParasQuery.data?.map((para) => (
// CSS ask is to reorder the mapped staff so that the selected staff are moved to the top of the list
<ListItem key={para.para_id} sx={{ px: 0, py: 0 }}>
<ListItemButton dense onClick={handleParaToggle(para.para_id)}>
<ListItemIcon sx={{ minWidth: "auto" }}>
<Checkbox
edge="start"
disableRipple
tabIndex={-1}
checked={selectedParaIds.includes(para.para_id)}
/>
</ListItemIcon>
<ListItemText>
{para.first_name} {para.last_name}
</ListItemText>
</ListItemButton>
</ListItem>
))}
</List>
</Box>
{/* 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 */}
{currentModalSelection === 1 && (
<Box>
<p>Select one or more paras:</p>
<Box
sx={{
my: 2,
maxHeight: "10rem",
overflow: "auto",
border: "1px solid #d6dde1",
borderRadius: 1,
}}
>
<List sx={{ p: 0 }} className={$subgoal.staffListItemText}>
{myParasQuery.data?.map((para) => (
// CSS ask is to reorder the mapped staff so that the selected staff are moved to the top of the list
<ListItem key={para.para_id} sx={{ px: 0, py: 0 }}>
<ListItemButton
dense
onClick={handleParaToggle(para.para_id)}
>
<ListItemIcon sx={{ minWidth: "auto" }}>
<Checkbox
edge="start"
disableRipple
tabIndex={-1}
checked={selectedParaIds.includes(para.para_id)}
/>
</ListItemIcon>
<ListItemText>
{para.first_name} {para.last_name}
</ListItemText>
</ListItemButton>
</ListItem>
))}
</List>
</Box>
</Box>
)}
{/* Enter 2nd selection process here, utilizing selected staff at the end of the process */}
{currentModalSelection === 2 && <Box></Box>}
<Box sx={{ display: "flex", justifyContent: "end" }}>
<Button
variant="contained"
onClick={handleClose}
onClick={() => setCurrentModalSelection(2)} //hide first selection process and open second
className={$subgoal.button}
>
Next
Expand Down

0 comments on commit 5d97320

Please sign in to comment.