diff --git a/src/app/dashboard/admin/programs/healthy-habits/page.tsx b/src/app/dashboard/admin/programs/healthy-habits/page.tsx
index 05257a7..d33fd20 100644
--- a/src/app/dashboard/admin/programs/healthy-habits/page.tsx
+++ b/src/app/dashboard/admin/programs/healthy-habits/page.tsx
@@ -1,11 +1,11 @@
import { Box, Typography } from "@mui/material";
import HealthyHabitsDashboard from "@/components/AdminDashboard/HealthyHabitsDashboard";
-import { getHealthHabitsProgramEnrollments } from "@/server/api/program-enrollments/queries";
+import { getHealthyHabitsProgramEnrollments } from "@/server/api/program-enrollments/queries";
export default async function HealthyHabits() {
- const [healthHabitsProgramEnrollments, error] =
- await getHealthHabitsProgramEnrollments();
+ const [healthyHabitsProgramEnrollments, error] =
+ await getHealthyHabitsProgramEnrollments();
if (error !== null) {
return (
@@ -25,14 +25,16 @@ export default async function HealthyHabits() {
return (
);
diff --git a/src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsClientDashboard.tsx b/src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsClientDashboard.tsx
index 916767c..4ed7f19 100644
--- a/src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsClientDashboard.tsx
+++ b/src/components/AdminDashboard/HealthyHabitsDashboard/HealthyHabitsClientDashboard.tsx
@@ -27,11 +27,7 @@ const createRowFromHealthyHabitsProgramEnrollment = (
let completed = false;
if (user.healthyHabitsTrackingForms.length > 0) {
- const date = dayjsUtil(user.healthyHabitsTrackingForms[0]?.submittedDate);
- const lastSunday = dayjsUtil()
- .subtract(dayjsUtil().day(), "day")
- .startOf("day");
-
+ const latestFormSubmission = user.healthyHabitsTrackingForms[0];
completed = date.isSame(lastSunday, "day");
}
@@ -50,42 +46,40 @@ function getRows(programEnrollments: ProgramEnrollment[]): Row[] {
}
type HealthyHabitsClientDashboardProps = {
- healthHabitsProgramEnrollments: ProgramEnrollment[];
+ healthyHabitsProgramEnrollments: ProgramEnrollment[];
};
export default function HealthyHabitsClientDashboard({
- healthHabitsProgramEnrollments,
+ healthyHabitsProgramEnrollments,
}: HealthyHabitsClientDashboardProps) {
- const rows = getRows(healthHabitsProgramEnrollments);
+ const rows = getRows(healthyHabitsProgramEnrollments);
const [searchQuery, setSearchQuery] = useState("");
const columns: GridColDef[] = [
{
field: "firstName",
headerName: "First name",
- width: 150,
+ flex: 1,
},
{
field: "lastName",
headerName: "Last name",
- width: 150,
+ flex: 1,
},
{
field: "phoneNumber",
headerName: "Phone Number",
- width: 125,
+ flex: 1,
},
{
field: "email",
headerName: "Email",
- minWidth: 200,
- flex: 1,
+ flex: 2,
},
{
field: "competed",
- headerName: "Completed",
+ headerName: "Completed tracking form this week?",
sortable: false,
- minWidth: 100,
flex: 1,
renderCell: (params) => {
const completed = params.row.completed;
@@ -120,7 +114,7 @@ export default function HealthyHabitsClientDashboard({
<>
- Health Habits
+ Healthy Habits Clients
Healthy Habits Metrics;
+ return (
+
+ Metrics
+
+ );
}
diff --git a/src/components/AdminDashboard/HealthyHabitsDashboard/index.tsx b/src/components/AdminDashboard/HealthyHabitsDashboard/index.tsx
index 0479a27..f4d10cc 100644
--- a/src/components/AdminDashboard/HealthyHabitsDashboard/index.tsx
+++ b/src/components/AdminDashboard/HealthyHabitsDashboard/index.tsx
@@ -10,11 +10,11 @@ import { ProgramEnrollment } from "@/types";
type HealthyHabitsSections = "clients" | "metrics";
type HealthyHabitsDashboardProps = {
- healthHabitsProgramEnrollments: ProgramEnrollment[];
+ healthyHabitsProgramEnrollments: ProgramEnrollment[];
};
export default function HealthyHabitsDashboard({
- healthHabitsProgramEnrollments,
+ healthyHabitsProgramEnrollments,
}: HealthyHabitsDashboardProps) {
const [selectedSection, setSelectedSection] =
useState("clients");
@@ -31,7 +31,7 @@ export default function HealthyHabitsDashboard({
case "clients":
return (
);
case "metrics":
@@ -46,17 +46,15 @@ export default function HealthyHabitsDashboard({
- {getSectionContent(selectedSection)}
+
+ {getSectionContent(selectedSection)}
+
>
);
diff --git a/src/server/api/program-enrollments/queries.ts b/src/server/api/program-enrollments/queries.ts
index 74a88e4..9514c68 100644
--- a/src/server/api/program-enrollments/queries.ts
+++ b/src/server/api/program-enrollments/queries.ts
@@ -76,12 +76,12 @@ export async function getProgramEnrollmentForUser(
}
}
-export async function getHealthHabitsProgramEnrollments(): Promise<
+export async function getHealthyHabitsProgramEnrollments(): Promise<
ApiResponse
> {
await dbConnect();
try {
- const healthHabitsEnrollments = ProgramEnrollmentModel.find({
+ const healthyHabitsEnrollments = await ProgramEnrollmentModel.find({
status: "accepted",
program: "Healthy Habits For The Long Haul",
})
@@ -100,7 +100,7 @@ export async function getHealthHabitsProgramEnrollments(): Promise<
.lean()
.exec();
- return [await healthHabitsEnrollments, null];
+ return [serializeMongooseObject(healthyHabitsEnrollments), null];
} catch (error) {
console.error(error);
return [null, handleMongooseError(error)];