-
Notifications
You must be signed in to change notification settings - Fork 3
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 #130 from tahmid-saj/dev-general-cleanup-2
dev-general-cleanup-2
- Loading branch information
Showing
15 changed files
with
272 additions
and
11 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
72 changes: 72 additions & 0 deletions
72
...s/signed-out/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,72 @@ | ||
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 { useDispatch, useSelector } from "react-redux"; | ||
import { selectNutritionTrackedDays } from "../../../../../store/signed-out/nutrition-tracker/nutrition-tracker.selector"; | ||
import { selectScheduledNutritionTrackedDay } from "../../../../../store/signed-out/nutrition-tracker/nutrition-tracker.action"; | ||
|
||
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 dispatch = useDispatch() | ||
const nutritionTrackedDays = useSelector(selectNutritionTrackedDays) | ||
|
||
// 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) | ||
dispatch(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
...nts/signed-out/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%; | ||
} |
54 changes: 54 additions & 0 deletions
54
...s/signed-out/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,54 @@ | ||
import "./schedule-day-info.styles.scss" | ||
import { useSelector } from "react-redux" | ||
import { selectScheduledNutritionTrackedDaysView } from "../../../../../store/signed-out/nutrition-tracker/nutrition-tracker.selector" | ||
import { Typography, Divider } from "@mui/material" | ||
import { Fragment } from "react" | ||
import SimplePaper from "../../../../shared/mui/paper/paper.component" | ||
import { COLOR_CODES } from "../../../../../utils/constants/shared.constants" | ||
|
||
const paperStyles = { | ||
backgroundColor: COLOR_CODES.general["1"], | ||
width: 400 | ||
} | ||
|
||
const ScheduleDayInfo = () => { | ||
const scheduledNutritionTrackedDaysView = useSelector(selectScheduledNutritionTrackedDaysView) | ||
|
||
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
...nts/signed-out/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
4 changes: 4 additions & 0 deletions
4
src/pages/signed-out/nutrition-tracker/nutrition-tracker.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
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
Oops, something went wrong.