-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add healthy habits client history modal to admin view (#104)
- Loading branch information
1 parent
351d256
commit 98a8f24
Showing
2 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsHistoryModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
"use client"; | ||
|
||
import InfoIcon from "@mui/icons-material/Info"; | ||
import { Box, Button, Fade, Modal, Typography } from "@mui/material"; | ||
import { useState } from "react"; | ||
|
||
import HealthyHabitsHistory from "@/components/ClientDashboard/HealthyHabits/HealthyHabitsHistory"; | ||
import { ClientUser, HealthyHabitsTrackingForm, User } from "@/types"; | ||
|
||
type HealthyHabitsHistoryModalProps = { | ||
trackingForms: HealthyHabitsTrackingForm[]; | ||
user: User; | ||
}; | ||
|
||
const style = { | ||
position: "absolute", | ||
top: "50%", | ||
left: "50%", | ||
transform: "translate(-50%, -50%)", | ||
width: "80vw", | ||
maxHeight: "80vh", | ||
overflowY: "auto", | ||
bgcolor: "background.paper", | ||
boxShadow: 2, | ||
p: 4, | ||
display: "flex", | ||
flexDirection: "column", | ||
alignItems: "center", | ||
gap: 2, | ||
}; | ||
|
||
export default function HealthyHabitsHistoryModal({ | ||
trackingForms, | ||
user, | ||
}: HealthyHabitsHistoryModalProps) { | ||
const [open, setOpen] = useState(false); | ||
|
||
return ( | ||
<Box width="100%"> | ||
{/* Info Button */} | ||
<Button variant="contained" onClick={() => setOpen(true)}> | ||
<InfoIcon /> | ||
</Button> | ||
|
||
{/* Modal */} | ||
<Modal | ||
aria-labelledby="transition-modal-title" | ||
aria-describedby="transition-modal-description" | ||
open={open} | ||
onClose={() => setOpen(false)} | ||
closeAfterTransition | ||
> | ||
<Fade in={open}> | ||
<Box sx={style}> | ||
<Typography variant="h4"> | ||
Healthy Habits Tracking Form History | ||
</Typography> | ||
<HealthyHabitsHistory | ||
initialForms={trackingForms} | ||
user={user as ClientUser} | ||
/> | ||
<Button | ||
variant="outlined" | ||
onClick={() => setOpen(false)} | ||
sx={{ width: "50%" }} | ||
> | ||
Close | ||
</Button> | ||
</Box> | ||
</Fade> | ||
</Modal> | ||
</Box> | ||
); | ||
} |