From fe7701866876f7e576521c33350d4184de6377c1 Mon Sep 17 00:00:00 2001 From: tahmid-saj Date: Tue, 18 Jun 2024 23:30:16 -0400 Subject: [PATCH] adding fitness to dashboard --- .../schedule-calendar.component.jsx | 107 ++++++++++++++++++ .../schedule-calendar.styles.scss | 27 +++++ .../schedule-day-info.component.jsx | 82 ++++++++++++++ .../schedule-day-info.styles.scss | 15 +++ .../dashboard/dashboard.component.jsx | 24 ++++ 5 files changed, 255 insertions(+) create mode 100644 src/components/signed-out/dashboard/fitness/schedule/schedule-calendar/schedule-calendar.component.jsx create mode 100644 src/components/signed-out/dashboard/fitness/schedule/schedule-calendar/schedule-calendar.styles.scss create mode 100644 src/components/signed-out/dashboard/fitness/schedule/schedule-day-info/schedule-day-info.component.jsx create mode 100644 src/components/signed-out/dashboard/fitness/schedule/schedule-day-info/schedule-day-info.styles.scss diff --git a/src/components/signed-out/dashboard/fitness/schedule/schedule-calendar/schedule-calendar.component.jsx b/src/components/signed-out/dashboard/fitness/schedule/schedule-calendar/schedule-calendar.component.jsx new file mode 100644 index 0000000..133375d --- /dev/null +++ b/src/components/signed-out/dashboard/fitness/schedule/schedule-calendar/schedule-calendar.component.jsx @@ -0,0 +1,107 @@ +import "./schedule-calendar.styles.scss" +import 'rsuite/Calendar/styles/index.css'; +import { Fragment, useContext, useState } from "react"; +import { Calendar, Whisper, Popover, Badge } from 'rsuite'; +import { Typography } from "@mui/material"; +import { FitnessContext } from "../../../../../../contexts/signed-out/fitness/fitness.context"; +import { COLOR_CODES } from "../../../../../../utils/constants/shared.constants"; + +function getScheduledData(date, exercises) { + // const day = date.getDate(); + date = date.toISOString().split('T')[0] + + // switch (day) { + // case 10: + // return [ + // { time: '10:30 am', title: 'Meeting' }, + // { time: '12:00 pm', title: 'Lunch' } + // ]; + // case 15: + // return [ + // { time: '09:30 pm', title: 'Products Introduction Meeting' }, + // { time: '12:30 pm', title: 'Client entertaining' }, + // { time: '02:00 pm', title: 'Product design discussion' }, + // { time: '05:00 pm', title: 'Product test and acceptance' }, + // { time: '06:30 pm', title: 'Reporting' }, + // { time: '10:00 pm', title: 'Going home to walk the dog' } + // ]; + // default: + // return []; + // } + + let scheduledExercisesForDate = [] + exercises.map((exercise) => { + if (exercise.exerciseDate === date) { + scheduledExercisesForDate.push({ + type: exercise.exerciseType, + name: exercise.exerciseName + }) + } + }) + + return scheduledExercisesForDate +} + +const ScheduleCalendar = () => { + const { exercises, selectScheduledExercise } = useContext(FitnessContext) + + function renderCell(date) { + const list = getScheduledData(date, exercises); + const displayList = list.filter((item, index) => index < 1); + + if (list.length) { + const moreCount = list.length - displayList.length; + // const moreItem = ( + //
  • + // + // {list.map((item, index) => ( + //

    + // {item.time} - {item.title} + //

    + // ))} + // + // } + // > + // {moreCount} more + //
    + //
  • + // ); + + return ( + + + {/* {moreCount} more */} + + ); + } + + return null; + } + + const onSelectDate = (date) => { + const selectedDate = date.toISOString().split('T')[0] + console.log(selectedDate) + selectScheduledExercise(selectedDate) + } + + return ( +
    + {`Exercises calendar`} + +
    + ) +} + +export default ScheduleCalendar \ No newline at end of file diff --git a/src/components/signed-out/dashboard/fitness/schedule/schedule-calendar/schedule-calendar.styles.scss b/src/components/signed-out/dashboard/fitness/schedule/schedule-calendar/schedule-calendar.styles.scss new file mode 100644 index 0000000..679c602 --- /dev/null +++ b/src/components/signed-out/dashboard/fitness/schedule/schedule-calendar/schedule-calendar.styles.scss @@ -0,0 +1,27 @@ +.calendar-todo-list { + text-align: left; + padding: 0; + list-style: none; +} + +.calendar-todo-list li { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.calendar-todo-item-badge { + vertical-align: top; + margin-top: 8px; + width: 6px; + height: 6px; +} + +.fitness-schedule-calendar-container { + display: block; + justify-content: center; + align-items: center; + background-color: lightblue; + margin: 2%; + padding: 1%; +} \ No newline at end of file diff --git a/src/components/signed-out/dashboard/fitness/schedule/schedule-day-info/schedule-day-info.component.jsx b/src/components/signed-out/dashboard/fitness/schedule/schedule-day-info/schedule-day-info.component.jsx new file mode 100644 index 0000000..6ebf3c4 --- /dev/null +++ b/src/components/signed-out/dashboard/fitness/schedule/schedule-day-info/schedule-day-info.component.jsx @@ -0,0 +1,82 @@ +import "./schedule-day-info.styles.scss" +import { useState, useContext, Fragment } from "react" +import { Typography } from "@mui/material"; + +import { AgGridReact } from 'ag-grid-react'; // React Data Grid Component +import "ag-grid-community/styles/ag-grid.css"; // Mandatory CSS required by the grid +import "ag-grid-community/styles/ag-theme-quartz.css"; // Optional Theme applied to the grid + +import SimplePaper from "../../../../../shared/mui/paper/paper.component"; +import { COLOR_CODES } from "../../../../../../utils/constants/shared.constants"; +import { FitnessContext } from "../../../../../../contexts/signed-out/fitness/fitness.context"; +import Button from "../../../../../shared/button/button.component"; +import { ButtonsContainer } from "../../../../../shared/button/button.styles"; + +const paperStyles = { + backgroundColor: COLOR_CODES.general["8"], + height: 600 +} + +const ScheduleDayInfo = () => { + const { exercisesView, removeExercise, unselectScheduledExercise } = useContext(FitnessContext) + console.log(exercisesView) + + const rowData = exercisesView.map((exercise) => { + return { + // AddToExpenses: "", + Date: exercise.exerciseDate, + Exercise: exercise.exerciseName, + Sets: exercise.exerciseSets, + Reps: exercise.exerciseReps, + Type: exercise.exerciseType, + Muscle: exercise.exerciseMuscle, + Equipment: exercise.exerciseEquipment, + Difficulty: exercise.exerciseDifficulty, + Instructions: exercise.exerciseInstructions, + Tag: exercise.exerciseTag + } + }) + + // column definitions + const [columnDefs, setColumnDefs] = useState([ + { field: "Date" }, + { field: "Exercise" }, + { field: "Sets" }, + { field: "Reps" }, + { field: "Type" }, + { field: "Muscle" }, + { field: "Equipment" }, + { field: "Difficulty" }, + { field: "Instructions" }, + { field: "Tag" }, + ]) + + const handleUnselect = (event) => { + event.preventDefault() + unselectScheduledExercise() + } + + return ( +
    + {`Exercises planned`} + + +
    + + +
    + +
    +
    +
    +
    +
    + ) +} + +export default ScheduleDayInfo \ No newline at end of file diff --git a/src/components/signed-out/dashboard/fitness/schedule/schedule-day-info/schedule-day-info.styles.scss b/src/components/signed-out/dashboard/fitness/schedule/schedule-day-info/schedule-day-info.styles.scss new file mode 100644 index 0000000..a10dff1 --- /dev/null +++ b/src/components/signed-out/dashboard/fitness/schedule/schedule-day-info/schedule-day-info.styles.scss @@ -0,0 +1,15 @@ +.fitness-schedule-day-info-container { + margin-bottom: 2%; +} + +.fitness-schedule-day-info { + display: block; + justify-content: center; + align-items: center; + padding: 1% 1% 0% 1%; +} + +.remove-exercise-selected-button, +.unselect-exercise-button { + margin: 1%; +} \ No newline at end of file diff --git a/src/pages/signed-out/dashboard/dashboard.component.jsx b/src/pages/signed-out/dashboard/dashboard.component.jsx index d65aa1a..4519628 100644 --- a/src/pages/signed-out/dashboard/dashboard.component.jsx +++ b/src/pages/signed-out/dashboard/dashboard.component.jsx @@ -14,12 +14,16 @@ import { selectNutritionTrackedDays, selectScheduledNutritionTrackedDaysView, import { selectScheduledNutritionTrackedDayHelper, setScheduledNutritionTrackedDaysView } from "../../../store/signed-out/nutrition-tracker/nutrition-tracker.action" import { CaloriesBurnedContext } from "../../../contexts/signed-out/calories-burned/calories-burned.context" +import { FitnessContext } from "../../../contexts/signed-out/fitness/fitness.context" import ChatBot from "../../shared/chatbot/chatbot.component" +import { Divider } from "@mui/material" import ScheduleCalendarNutritionTracker from "../../../components/signed-out/dashboard/nutrition-tracker/schedule/schedule-calendar/schedule-calendar.component" import ScheduleDayInfoNutritionTracker from "../../../components/signed-out/dashboard/nutrition-tracker/schedule/schedule-day-info/schedule-day-info.component" import ScheduleCalendarCaloriesBurned from "../../../components/signed-out/dashboard/calories-burned/schedule/schedule-calendar/schedule-calendar.component" import ScheduleDayInfoCaloriesBurned from "../../../components/signed-out/dashboard/calories-burned/schedule/schedule-day-info/schedule-day-info.component" +import ScheduleCalendarFitness from "../../../components/signed-out/dashboard/fitness/schedule/schedule-calendar/schedule-calendar.component" +import ScheduleDayInfoFitness from "../../../components/signed-out/dashboard/fitness/schedule/schedule-day-info/schedule-day-info.component" const Dashboard = () => { const dispatch = useDispatch() @@ -28,6 +32,7 @@ const Dashboard = () => { const selectedNutritionTrackedDay = useSelector(selectSelectedNutritionTrackedDay) const { trackedCaloriesBurned, scheduledTrackedCaloriesBurnedView } = useContext(CaloriesBurnedContext) + const { exercises, selectedSearchedExercise } = useContext(FitnessContext) // update scheduledNutritionTrackedDaysView when nutritionTrackedDays or selectedNutritionTrackedDay change useEffect(() => { @@ -90,6 +95,25 @@ const Dashboard = () => { } + + { + exercises.length !== 0 && + +
    +
    +
    +
    +

    Fitness

    + + +
    + +
    + + +
    +
    + } ) }