Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update styling for HealthyHabitsHistory #79

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function WeightLineChart({
<Box
sx={{
height: 200,
width: "90vw",
width: "100%",
}}
>
<Typography variant="h6" sx={{ marginBottom: 2 }}>
Expand All @@ -51,6 +51,7 @@ export default function WeightLineChart({
data: chartData.map((item) => item.y),
label: "Weight (lbs)",
color: theme.palette.primary.main,
curve: "linear",
},
]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function HealthyHabitsHistory({
return (
<Box
sx={{
width: "min(90vw, 700px)",
display: "flex",
flexDirection: "column",
justifyContent: "center",
Expand Down
36 changes: 15 additions & 21 deletions src/components/ClientDashboard/HealthyHabits/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,7 @@ import HealthyHabitsInfo from "@/components/ClientDashboard/HealthyHabits/Health
import HealthyHabitsTracking from "@/components/ClientDashboard/HealthyHabits/HealthyHabitsTracking";
import { HealthyHabitsTrackingForm } from "@/types";

export type HealthyHabitsSections = "tracking" | "history" | "info";

function getSectionContent(
section: HealthyHabitsSections,
email: string,
trackingForms: HealthyHabitsTrackingForm[],
) {
switch (section) {
case "tracking":
return <HealthyHabitsTracking email={email} />;
case "history":
return <HealthyHabitsHistory trackingForms={trackingForms} />;
case "info":
return <HealthyHabitsInfo />;
default:
return <Typography>Invalid section</Typography>;
}
}
type HealthyHabitsSections = "tracking" | "history" | "info";

type HealthyHabitsProps = {
email: string;
Expand All @@ -45,6 +28,19 @@ export default function HealthyHabits({
setSelectedSection(newValue);
};

function getSectionContent(section: HealthyHabitsSections) {
switch (section) {
case "tracking":
return <HealthyHabitsTracking email={email} />;
case "history":
return <HealthyHabitsHistory trackingForms={trackingForms} />;
case "info":
return <HealthyHabitsInfo />;
default:
return <Typography>Invalid section</Typography>;
}
}

return (
<>
<Box
Expand All @@ -71,9 +67,7 @@ export default function HealthyHabits({
</Tabs>
</Box>
<Divider sx={{ width: "80vw", marginTop: 2 }} />
<Box sx={{ marginTop: 3 }}>
{getSectionContent(selectedSection, email, trackingForms)}
</Box>
<Box sx={{ marginTop: 3 }}>{getSectionContent(selectedSection)}</Box>
</>
);
}
8 changes: 0 additions & 8 deletions src/server/api/healthy-habits-tracking-forms/queries.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import dbConnect from "@/server/dbConnect";
import { HealthyHabitsTrackingFormModel } from "@/server/models";
import { ApiResponse, HealthyHabitsTrackingForm } from "@/types";
import apiErrors from "@/utils/constants/apiErrors";
import handleMongooseError from "@/utils/handleMongooseError";

type HealthyHabitsTrackingFormFilters = Partial<HealthyHabitsTrackingForm>;
Expand All @@ -17,13 +16,6 @@ async function getHealthyHabitsTrackingForms(
.lean<HealthyHabitsTrackingForm[]>()
.exec();

if (!healthyHabitsTrackingForms) {
return [
null,
apiErrors.healthyHabitsTrackingForm.healthyHabitsTrackingFormNotFound,
];
}

// convert ObjectId to string
healthyHabitsTrackingForms.forEach((healthyHabitsTrackingForm) => {
healthyHabitsTrackingForm._id = String(healthyHabitsTrackingForm._id);
Expand Down
Loading