From 98a8f24fc120f86cd864462e913514dedc237c20 Mon Sep 17 00:00:00 2001 From: Rudra Patel <85089368+RudraPatel2003@users.noreply.github.com> Date: Sun, 26 Jan 2025 22:54:08 -0500 Subject: [PATCH] feat: Add healthy habits client history modal to admin view (#104) --- .../HealthyHabitsClientDashboard.tsx | 36 ++++++++- .../HealthyHabitsHistoryModal.tsx | 74 +++++++++++++++++++ 2 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsHistoryModal.tsx diff --git a/src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsClientDashboard.tsx b/src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsClientDashboard.tsx index 2168714..4335b8f 100644 --- a/src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsClientDashboard.tsx +++ b/src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsClientDashboard.tsx @@ -7,17 +7,26 @@ import { Box, TextField, Typography } from "@mui/material"; import { DataGrid, GridColDef } from "@mui/x-data-grid"; import { useState } from "react"; -import { ClientUser, ProgramEnrollment } from "@/types"; +import { + ClientUser, + HealthyHabitsTrackingForm, + ProgramEnrollment, + User, +} from "@/types"; import dayjsUtil from "@/utils/dayjsUtil"; import getClosestPastSunday from "@/utils/getClosestPastSunday"; +import HealthyHabitsHistoryModal from "./HealthyHabitsHistoryModal"; + export type Row = { id?: string; lastName: string; firstName: string; phoneNumber: string; email: string; + trackingForms: HealthyHabitsTrackingForm[]; completed: boolean; + user: User; }; const createRowFromHealthyHabitsProgramEnrollment = ( @@ -44,7 +53,9 @@ const createRowFromHealthyHabitsProgramEnrollment = ( firstName: user.firstName, phoneNumber: user.enrollmentForm.generalInformationSection.phoneNumber, email: user.email, + trackingForms: user.healthyHabitsTrackingForms, completed, + user, }; }; @@ -67,27 +78,48 @@ export default function HealthyHabitsClientDashboard({ field: "firstName", headerName: "First name", flex: 1, + minWidth: 150, }, { field: "lastName", headerName: "Last name", flex: 1, + minWidth: 150, }, { field: "phoneNumber", headerName: "Phone Number", flex: 1, + minWidth: 125, }, { field: "email", headerName: "Email", flex: 2, + minWidth: 200, + }, + { + field: "history", + headerName: "View history", + sortable: false, + align: "center", + flex: 1, + minWidth: 100, + renderCell: (params) => { + return ( + + ); + }, }, { - field: "competed", + field: "completed", headerName: "Completed tracking form this week?", sortable: false, flex: 1, + minWidth: 250, renderCell: (params) => { const completed = params.row.completed; diff --git a/src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsHistoryModal.tsx b/src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsHistoryModal.tsx new file mode 100644 index 0000000..d06a3ef --- /dev/null +++ b/src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsHistoryModal.tsx @@ -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 ( + + {/* Info Button */} + + + {/* Modal */} + setOpen(false)} + closeAfterTransition + > + + + + Healthy Habits Tracking Form History + + + + + + + + ); +}