-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from tahmid-saj/dev-general-cleanup-2
adding calories burned calendar to dashboard
- Loading branch information
Showing
14 changed files
with
187 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...-out/dashboard/calories-burned/schedule/schedule-calendar/schedule-calendar.component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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 { COLOR_CODES } from "../../../../../../utils/constants/shared.constants"; | ||
|
||
import { CaloriesBurnedContext } from "../../../../../../contexts/signed-out/calories-burned/calories-burned.context"; | ||
|
||
function getScheduledData(date, trackedCaloriesBurned) { | ||
date = date.toISOString().split('T')[0] | ||
|
||
let scheduledTrackedCaloriesBurnedForDate = [] | ||
trackedCaloriesBurned.map((trackedDay) => { | ||
if (trackedDay.dateTracked === date) { | ||
scheduledTrackedCaloriesBurnedForDate.push({ | ||
caloriesBurned: trackedDay.totalCaloriesBurned | ||
}) | ||
} | ||
}) | ||
|
||
return scheduledTrackedCaloriesBurnedForDate | ||
} | ||
|
||
const ScheduleCalendar = () => { | ||
const { trackedCaloriesBurned, selectScheduledTrackedCaloriesBurned } = useContext(CaloriesBurnedContext) | ||
|
||
function renderCell(date) { | ||
const list = getScheduledData(date, trackedCaloriesBurned); | ||
const displayList = list.filter((item, index) => index < 1); | ||
|
||
if (list.length) { | ||
const moreCount = list.length - displayList.length; | ||
|
||
return ( | ||
<Fragment> | ||
<ul className="calendar-todo-list"> | ||
{displayList.map((item, index) => ( | ||
<li key={index}> | ||
<Badge /> <b>{`Calories: ${item.caloriesBurned}`}</b> | ||
</li> | ||
))} | ||
{moreCount ? `${moreCount} more` : null} | ||
</ul> | ||
{/* {moreCount} more */} | ||
</Fragment> | ||
); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
const onSelectDate = (date) => { | ||
const selectedDate = date.toISOString().split('T')[0] | ||
console.log(selectedDate) | ||
selectScheduledTrackedCaloriesBurned(selectedDate) | ||
} | ||
|
||
return ( | ||
<div className="calories-burned-schedule-calendar-container" style={{ backgroundColor: COLOR_CODES.general["0"] }}> | ||
<Typography sx={{ display: "flex", marginLeft: "1%" }} | ||
variant="h6">{`Calories burned calendar`}</Typography> | ||
<Calendar bordered renderCell={ renderCell } onSelect={ onSelectDate } style={{ backgroundColor: COLOR_CODES.general["0"] }}/> | ||
</div> | ||
) | ||
} | ||
|
||
export default ScheduleCalendar |
26 changes: 26 additions & 0 deletions
26
...ed-out/dashboard/calories-burned/schedule/schedule-calendar/schedule-calendar.styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.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; | ||
} | ||
|
||
.calories-burned-calendar-container { | ||
display: block; | ||
justify-content: center; | ||
align-items: center; | ||
margin: 2%; | ||
padding: 1%; | ||
} |
42 changes: 42 additions & 0 deletions
42
...-out/dashboard/calories-burned/schedule/schedule-day-info/schedule-day-info.component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import "./schedule-day-info.styles.scss" | ||
import { Typography, Divider } from "@mui/material" | ||
import { Fragment, useContext } from "react" | ||
import SimplePaper from "../../../../../shared/mui/paper/paper.component" | ||
import { COLOR_CODES } from "../../../../../../utils/constants/shared.constants" | ||
import { CaloriesBurnedContext } from "../../../../../../contexts/signed-out/calories-burned/calories-burned.context" | ||
|
||
const paperStyles = { | ||
backgroundColor: COLOR_CODES.general["1"], | ||
width: 400 | ||
} | ||
|
||
const ScheduleDayInfo = () => { | ||
const { scheduledTrackedCaloriesBurnedView } = useContext(CaloriesBurnedContext) | ||
|
||
if (!scheduledTrackedCaloriesBurnedView.length) return <Fragment/> | ||
|
||
return ( | ||
<div className="calories-burned-schedule-day-info"> | ||
{ | ||
scheduledTrackedCaloriesBurnedView.map((trackedCaloriesBurned) => { | ||
return ( | ||
<SimplePaper styles={ paperStyles }> | ||
<Typography sx={{ display: "flex", justifyContent: "center" }} variant="h6">{`${trackedCaloriesBurned.dateTracked}`}</Typography> | ||
<Typography sx={{ display: "flex", justifyContent: "center" }} variant="body1">{`Activity - ${trackedCaloriesBurned.activity}`}</Typography> | ||
<Typography sx={{ display: "flex", justifyContent: "center" }} variant="body1">{`Total calories burned - ${trackedCaloriesBurned.totalCaloriesBurned}`}</Typography> | ||
|
||
<br/> | ||
<Divider/> | ||
<br/> | ||
|
||
<Typography sx={{ display: "flex", justifyContent: "center" }} variant="body1">{`Duration (mins) - ${trackedCaloriesBurned.durationMinutes}`}</Typography> | ||
<Typography sx={{ display: "flex", justifyContent: "center" }} variant="body1">{`Calories burned / hr - ${trackedCaloriesBurned.caloriesBurnedPerHour}`}</Typography> | ||
</SimplePaper> | ||
) | ||
}) | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
export default ScheduleDayInfo |
6 changes: 6 additions & 0 deletions
6
...ed-out/dashboard/calories-burned/schedule/schedule-day-info/schedule-day-info.styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.calories-burned-schedule-day-info { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 2% 2% 2% 2%; | ||
} |
2 changes: 0 additions & 2 deletions
2
...n-tracker/nutrition-tracker-graph-calories/nutrition-tracker-graph-calories.component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...trition-tracker-graph-macronutrients/nutrition-tracker-graph-macronutrients.component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
...ion-tracker-summary/nutrition-tracker-graph-pie/nutrition-tracker-graph-pie.component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
...board/nutrition-tracker/nutrition-tracker-summary/nutrition-tracker-summary.component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ut/dashboard/nutrition-tracker/schedule/schedule-calendar/schedule-calendar.component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters