Skip to content

Commit

Permalink
feat: Add sleep, energy, and emotional health rankings
Browse files Browse the repository at this point in the history
  • Loading branch information
RudraPatel2003 committed Jan 5, 2025
1 parent 8264cb8 commit ce6c556
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,28 @@ export default function HealthyHabitsHistory({
title="Movement Minutes"
/>

{/* <ModularBarChart
trackingForms={trackingForms.filter((form) => form.sleepQuality)}
<ModularBarChart
trackingForms={trackingForms.filter((form) => form.sleepRanking)}
graphLabel="Sleep Quality"
dataKey="sleepQuality"
dataKey="sleepRanking"
title="Sleep Quality"
/>

<ModularBarChart
trackingForms={trackingForms.filter((form) => form.energyLevel)}
trackingForms={trackingForms.filter((form) => form.energyRanking)}
graphLabel="Energy Level"
dataKey="energyLevel"
dataKey="energyRanking"
title="Energy Level"
/>

<ModularBarChart
trackingForms={trackingForms.filter((form) => form.emotionalHealth)}
trackingForms={trackingForms.filter(
(form) => form.emotionalHealthRanking,
)}
graphLabel="Emotional Health"
dataKey="emotionalHealth"
dataKey="emotionalHealthRanking"
title="Emotional Health"
/> */}
/>
</Box>
);
}
104 changes: 104 additions & 0 deletions src/components/ClientDashboard/HealthyHabits/HealthyHabitsTracking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
FormControl,
FormControlLabel,
FormHelperText,
FormLabel,
InputAdornment,
Radio,
RadioGroup,
Snackbar,
Typography,
} from "@mui/material";
Expand Down Expand Up @@ -70,6 +73,9 @@ export default function HealthyHabitsTracking({
a1c: 0,
cholesterol: 0,
qualitativeGoals: "",
sleepRanking: 1,
energyRanking: 1,
emotionalHealthRanking: 1,
},
});

Expand Down Expand Up @@ -427,6 +433,104 @@ export default function HealthyHabitsTracking({
required
/>

<Divider />

<Typography variant="h6">Self Assessment</Typography>
<Typography>
For each question, rank your overall health in various categories. A
1 is the worst score and a 5 is the best score.
</Typography>

<FormControl
error={!!errors.sleepRanking?.message}
sx={{ width: "100%" }}
>
<FormLabel>
On a scale of 1-5, rank your overall health when it comes to
sleep:
</FormLabel>
<Controller
name="sleepRanking"
control={control}
render={({ field }) => (
<RadioGroup
{...field}
value={field.value.toString()}
onChange={(e) => field.onChange(Number(e.target.value))}
>
<FormControlLabel value="1" control={<Radio />} label="1" />
<FormControlLabel value="2" control={<Radio />} label="2" />
<FormControlLabel value="3" control={<Radio />} label="3" />
<FormControlLabel value="4" control={<Radio />} label="4" />
<FormControlLabel value="5" control={<Radio />} label="5" />
</RadioGroup>
)}
/>
<FormHelperText sx={{ m: 0 }}>
{errors.sleepRanking?.message}
</FormHelperText>
</FormControl>

<FormControl
error={!!errors.energyRanking?.message}
sx={{ width: "100%" }}
>
<FormLabel>
On a scale of 1-5, rank your overall health when it comes to
energy:
</FormLabel>
<Controller
name="energyRanking"
control={control}
render={({ field }) => (
<RadioGroup
{...field}
value={field.value.toString()}
onChange={(e) => field.onChange(Number(e.target.value))}
>
<FormControlLabel value="1" control={<Radio />} label="1" />
<FormControlLabel value="2" control={<Radio />} label="2" />
<FormControlLabel value="3" control={<Radio />} label="3" />
<FormControlLabel value="4" control={<Radio />} label="4" />
<FormControlLabel value="5" control={<Radio />} label="5" />
</RadioGroup>
)}
/>
<FormHelperText sx={{ m: 0 }}>
{errors.energyRanking?.message}
</FormHelperText>
</FormControl>

<FormControl
error={!!errors.emotionalHealthRanking?.message}
sx={{ width: "100%" }}
>
<FormLabel>
On a scale of 1-5, rank your overall health when it comes to
emotional health:
</FormLabel>
<Controller
name="emotionalHealthRanking"
control={control}
render={({ field }) => (
<RadioGroup
{...field}
value={field.value.toString()}
onChange={(e) => field.onChange(Number(e.target.value))}
>
<FormControlLabel value="1" control={<Radio />} label="1" />
<FormControlLabel value="2" control={<Radio />} label="2" />
<FormControlLabel value="3" control={<Radio />} label="3" />
<FormControlLabel value="4" control={<Radio />} label="4" />
<FormControlLabel value="5" control={<Radio />} label="5" />
</RadioGroup>
)}
/>
<FormHelperText sx={{ m: 0 }}>
{errors.emotionalHealthRanking?.message}
</FormHelperText>
</FormControl>

{/* Submit */}
<LoadingButton
type="submit"
Expand Down
3 changes: 3 additions & 0 deletions src/server/models/HealthyHabitsTrackingForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const HealthyHabitsTrackingFormSchema = new Schema<HealthyHabitsTrackingForm>(
a1c: { type: Number, required: true },
cholesterol: { type: Number, required: true },
qualitativeGoals: { type: String, required: true },
sleepRanking: { type: Number, required: true },
energyRanking: { type: Number, required: true },
emotionalHealthRanking: { type: Number, required: true },
},
{ versionKey: false },
);
Expand Down
3 changes: 3 additions & 0 deletions src/types/HealthyHabitsTrackingForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export const healthyHabitsValidator = z.object({
a1c: z.number().int().positive(),
cholesterol: z.number().int().positive(),
qualitativeGoals: z.string(),
sleepRanking: z.number().int().min(1).max(5),
energyRanking: z.number().int().min(1).max(5),
emotionalHealthRanking: z.number().int().min(1).max(5),
});

export type HealthyHabitsFormValues = z.infer<typeof healthyHabitsValidator>;
Expand Down

0 comments on commit ce6c556

Please sign in to comment.