-
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 #126 from tahmid-saj/dev-fitness-context
updating fitness for signed in
- Loading branch information
Showing
27 changed files
with
1,045 additions
and
16 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
37 changes: 37 additions & 0 deletions
37
...-in/fitness/add-exercise-form/add-exercise-form-info/add-exercise-form-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,37 @@ | ||
import "./add-exercise-form-info.styles.scss" | ||
import { Divider, Typography } from "@mui/material" | ||
import { FitnessContext } from "../../../../../contexts/signed-in/fitness/fitness.context" | ||
import { useContext } from "react" | ||
|
||
const AddExerciseFormInfo = () => { | ||
const { selectedSearchedExercise } = useContext(FitnessContext) | ||
|
||
return ( | ||
<div className="fitness-add-exercise-form-info"> | ||
<Typography sx={{ display: "flex" }} | ||
variant="body1">{`${selectedSearchedExercise.exerciseName}`}</Typography> | ||
<Typography sx={{ display: "flex" }} | ||
variant="body1">{`Type: ${selectedSearchedExercise.exerciseType}`}</Typography> | ||
|
||
<br/> | ||
<Divider/> | ||
<br/> | ||
|
||
<Typography sx={{ display: "flex" }} | ||
variant="body1">{`Muscle: ${selectedSearchedExercise.exerciseMuscle}`}</Typography> | ||
<Typography sx={{ display: "flex" }} | ||
variant="body1">{`Equipment: ${selectedSearchedExercise.exerciseEquipment}`}</Typography> | ||
<Typography sx={{ display: "flex" }} | ||
variant="body1">{`Difficulty: ${selectedSearchedExercise.exerciseDifficulty}`}</Typography> | ||
|
||
<br/> | ||
<Divider/> | ||
<br/> | ||
|
||
<Typography sx={{ display: "flex", whiteSpace: "pre-wrap" }} | ||
variant="body1">{`Instructions: \n\n${selectedSearchedExercise.exerciseInstructions}`}</Typography> | ||
</div> | ||
) | ||
} | ||
|
||
export default AddExerciseFormInfo |
Empty file.
81 changes: 81 additions & 0 deletions
81
src/components/signed-in/fitness/add-exercise-form/add-exercise-form.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,81 @@ | ||
import { Fragment, useContext, useState } from "react" | ||
import "./add-exercise-form.styles.scss" | ||
import { Typography } from "@mui/material" | ||
import FormInput from "../../../shared/form-input/form-input.component" | ||
import { ButtonsContainer } from "../../../shared/button/button.styles" | ||
import Button from "../../../shared/button/button.component" | ||
import SimplePaper from "../../../shared/mui/paper/paper.component" | ||
import { COLOR_CODES } from "../../../../utils/constants/shared.constants" | ||
import AddExerciseFormInfo from "./add-exercise-form-info/add-exercise-form-info.component" | ||
import { FitnessContext } from "../../../../contexts/signed-in/fitness/fitness.context" | ||
|
||
const defaultFormFields = { | ||
exerciseDate: "", | ||
exerciseSets: "", | ||
exerciseReps: "" | ||
} | ||
|
||
const paperStyles = { | ||
backgroundColor: COLOR_CODES.paper.formPaper, | ||
} | ||
|
||
const AddExerciseForm = () => { | ||
const [formFields, setFormFields] = useState(defaultFormFields) | ||
const { addExercise, selectedSearchedExercise } = useContext(FitnessContext) | ||
|
||
if (!selectedSearchedExercise) { | ||
return ( | ||
<Fragment></Fragment> | ||
) | ||
} | ||
|
||
const resetFormFields = () => { | ||
setFormFields(defaultFormFields) | ||
} | ||
|
||
const handleSubmit = (event) => { | ||
event.preventDefault() | ||
|
||
if (!formFields.exerciseDate || formFields.exerciseDate === "") { | ||
console.log("please fill in all info") | ||
return | ||
} | ||
|
||
addExercise(formFields) | ||
resetFormFields() | ||
} | ||
|
||
const handleChange = (event) => { | ||
const { name, value } = event.target | ||
|
||
setFormFields({ ...formFields, [name]: value }) | ||
} | ||
|
||
return ( | ||
<div className="fitness-add-exercise-form-container"> | ||
<Typography variant="h6">Add exercise to the schedule</Typography> | ||
|
||
<SimplePaper styles={ paperStyles }> | ||
<AddExerciseFormInfo></AddExerciseFormInfo> | ||
|
||
<form onSubmit={ handleSubmit } className="fitness-add-exercise-form"> | ||
<FormInput label="Scheduled date" type="date" required onChange={ handleChange } | ||
name="exerciseDate" value={ formFields.exerciseDate }></FormInput> | ||
|
||
<FormInput label="Sets" type="text" onChange={ handleChange } | ||
name="exerciseSets" value={ formFields.exerciseSets }></FormInput> | ||
|
||
<FormInput label="Reps" type="text" onChange={ handleChange } | ||
name="exerciseReps" value={ formFields.exerciseReps }></FormInput> | ||
|
||
<ButtonsContainer> | ||
<Button type="submit">Add</Button> | ||
<Button type="button" onClick={ resetFormFields }>Clear</Button> | ||
</ButtonsContainer> | ||
</form> | ||
</SimplePaper> | ||
</div> | ||
) | ||
} | ||
|
||
export default AddExerciseForm |
13 changes: 13 additions & 0 deletions
13
src/components/signed-in/fitness/add-exercise-form/add-exercise-form.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,13 @@ | ||
.fitness-add-exercise-form-container { | ||
display: block; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 0% 10% 2% 10%; | ||
width: 50%; | ||
} | ||
|
||
.fitness-add-exercise-form { | ||
display: block; | ||
justify-content: center; | ||
align-items: center; | ||
} |
106 changes: 106 additions & 0 deletions
106
src/components/signed-in/fitness/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,106 @@ | ||
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-in/fitness/fitness.context"; | ||
|
||
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 = ( | ||
// <li> | ||
// <Whisper | ||
// placement="top" | ||
// trigger="click" | ||
// speaker={ | ||
// <Popover> | ||
// {list.map((item, index) => ( | ||
// <p key={index}> | ||
// <b>{item.time}</b> - {item.title} | ||
// </p> | ||
// ))} | ||
// </Popover> | ||
// } | ||
// > | ||
// <h10>{moreCount} more</h10> | ||
// </Whisper> | ||
// </li> | ||
// ); | ||
|
||
return ( | ||
<Fragment> | ||
<ul className="calendar-todo-list"> | ||
{displayList.map((item, index) => ( | ||
<li key={index}> | ||
<Badge /> <b>{item.type}</b> - {item.name} | ||
</li> | ||
))} | ||
{/* {moreCount ? moreItem : null} */} | ||
</ul> | ||
{moreCount} more | ||
</Fragment> | ||
); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
const onSelectDate = (date) => { | ||
const selectedDate = date.toISOString().split('T')[0] | ||
console.log(selectedDate) | ||
selectScheduledExercise(selectedDate) | ||
} | ||
|
||
return ( | ||
<div className="fitness-schedule-calendar-container"> | ||
<Typography sx={{ display: "flex", marginLeft: "1%" }} | ||
variant="h6">{`Exercises calendar`}</Typography> | ||
<Calendar bordered renderCell={ renderCell } onSelect={ onSelectDate }/> | ||
</div> | ||
) | ||
} | ||
|
||
export default ScheduleCalendar |
27 changes: 27 additions & 0 deletions
27
src/components/signed-in/fitness/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,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%; | ||
} |
Oops, something went wrong.