-
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 #131 from tahmid-saj/dev-general-cleanup-2
calendar in nutrition tracker signed in
- Loading branch information
Showing
8 changed files
with
208 additions
and
8 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
...ts/signed-in/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
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 { NutritionTrackerContext } from "../../../../../contexts/signed-in/nutrition-tracker/nutrition-tracker.context"; | ||
|
||
function getScheduledData(date, nutritionTrackedDays) { | ||
date = date.toISOString().split('T')[0] | ||
|
||
let scheduledNutritionTrackedDaysForDate = [] | ||
nutritionTrackedDays.map((nutritionTrackedDay) => { | ||
if (nutritionTrackedDay.dateTracked === date) { | ||
scheduledNutritionTrackedDaysForDate.push({ | ||
calories: nutritionTrackedDay.calories | ||
}) | ||
} | ||
}) | ||
|
||
return scheduledNutritionTrackedDaysForDate | ||
} | ||
|
||
const ScheduleCalendar = () => { | ||
const { nutritionTrackedDays, selectScheduledNutritionTrackedDay } = useContext(NutritionTrackerContext) | ||
|
||
// console.log(nutritionTrackedDays) | ||
|
||
function renderCell(date) { | ||
const list = getScheduledData(date, nutritionTrackedDays); | ||
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.calories}`}</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) | ||
selectScheduledNutritionTrackedDay(selectedDate) | ||
} | ||
|
||
return ( | ||
<div className="nutrition-tracker-schedule-calendar-container" style={{ backgroundColor: COLOR_CODES.general["0"] }}> | ||
<Typography sx={{ display: "flex", marginLeft: "1%" }} | ||
variant="h6">{`Nutrition tracker 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
...ents/signed-in/nutrition-tracker/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; | ||
} | ||
|
||
.fitness-schedule-calendar-container { | ||
display: block; | ||
justify-content: center; | ||
align-items: center; | ||
margin: 2%; | ||
padding: 1%; | ||
} |
53 changes: 53 additions & 0 deletions
53
...ts/signed-in/nutrition-tracker/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,53 @@ | ||
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 { NutritionTrackerContext } from "../../../../../contexts/signed-in/nutrition-tracker/nutrition-tracker.context" | ||
|
||
const paperStyles = { | ||
backgroundColor: COLOR_CODES.general["1"], | ||
width: 400 | ||
} | ||
|
||
const ScheduleDayInfo = () => { | ||
const { scheduledNutritionTrackedDaysView } = useContext(NutritionTrackerContext) | ||
|
||
return ( | ||
<div className="nutrition-tracker-schedule-day-info"> | ||
<SimplePaper styles={ paperStyles }> | ||
<Typography sx={{ display: "flex", justifyContent: "center" }} variant="h6">{`${scheduledNutritionTrackedDaysView.dateTracked}`}</Typography> | ||
<Typography sx={{ display: "flex", justifyContent: "center" }} variant="body1">{`Calories - ${scheduledNutritionTrackedDaysView.calories}`}</Typography> | ||
|
||
<br/> | ||
<Divider/> | ||
<br/> | ||
|
||
<strong><h4>Macronutrients</h4></strong> | ||
<Typography sx={{ display: "flex", justifyContent: "center" }} variant="body1">{`Carbohydrates - ${scheduledNutritionTrackedDaysView.macronutrients.carbohydrates} g`}</Typography> | ||
<Typography sx={{ display: "flex", justifyContent: "center" }} variant="body1">{`Protein - ${scheduledNutritionTrackedDaysView.macronutrients.protein} g`}</Typography> | ||
<Typography sx={{ display: "flex", justifyContent: "center" }} variant="body1">{`Fat - ${scheduledNutritionTrackedDaysView.macronutrients.fat} g`}</Typography> | ||
|
||
{ | ||
scheduledNutritionTrackedDaysView.micronutrients && scheduledNutritionTrackedDaysView.micronutrients.length !== 0 ? | ||
<Fragment> | ||
<br/> | ||
<Divider/> | ||
<br/> | ||
|
||
<strong><h4>Micronutrients</h4></strong> | ||
{ | ||
scheduledNutritionTrackedDaysView.micronutrients.map((micronutrient) => { | ||
return ( | ||
<Typography sx={{ display: "flex", justifyContent: "center" }} variant="body1">{`${micronutrient.name} - ${micronutrient.amount} ${micronutrient.unit}`}</Typography> | ||
) | ||
}) | ||
} | ||
</Fragment> : null | ||
} | ||
</SimplePaper> | ||
</div> | ||
) | ||
} | ||
|
||
export default ScheduleDayInfo |
6 changes: 6 additions & 0 deletions
6
...ents/signed-in/nutrition-tracker/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 @@ | ||
.nutrition-tracker-schedule-day-info { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 2% 2% 2% 2%; | ||
} |
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