-
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 #322 from bounswe/TrainingProgramUpdated
Training program updated
- Loading branch information
Showing
12 changed files
with
1,152 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
349 changes: 349 additions & 0 deletions
349
frontend/src/components/Detailed_Ex_Modal.component.jsx
Large diffs are not rendered by default.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
frontend/src/components/Detailed_Training_Modal.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,85 @@ | ||
import React from 'react'; | ||
import { | ||
Modal, | ||
ModalOverlay, | ||
ModalContent, | ||
ModalHeader, | ||
ModalFooter, | ||
ModalBody, | ||
ModalCloseButton, | ||
Button, | ||
Table, | ||
Thead, | ||
Tbody, | ||
Tr, | ||
Th, | ||
Td, | ||
UnorderedList, | ||
ListItem, | ||
} from '@chakra-ui/react'; | ||
import { useNavigate } from '@tanstack/react-router'; | ||
import { LinkIcon } from '@chakra-ui/icons'; | ||
|
||
const Detailed_Training_Modal = ({ isOpen, onClose, data }) => { | ||
const navigate = useNavigate(); | ||
|
||
const VisitTraining = (program_id) => { | ||
navigate({ | ||
to: `/training?trainingId=${program_id}`, | ||
}); | ||
}; | ||
|
||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose}> | ||
<ModalOverlay /> | ||
<ModalContent maxWidth="90%" width="60%"> | ||
<ModalHeader>{data.title} Detailed Description</ModalHeader> | ||
<ModalCloseButton /> | ||
<ModalBody> | ||
<Table variant="striped" width="100%"> | ||
<Thead> | ||
<Tr> | ||
<Th>Week</Th> | ||
<Th>Workout</Th> | ||
<Th>List of Exercises</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
{data.weeks.map((week) => | ||
week.workouts.map((workout) => ( | ||
<Tr key={workout.id}> | ||
<Td>Week {week.weekNumber}</Td> | ||
<Td>{workout.name}</Td> | ||
<Td> | ||
<UnorderedList> | ||
{workout.workoutExercises.map((exerciseob) => ( | ||
<ListItem key={exerciseob.id} textAlign="left"> | ||
{exerciseob.exercise.name} | ||
</ListItem> | ||
))} | ||
</UnorderedList> | ||
</Td> | ||
</Tr> | ||
)) | ||
)} | ||
</Tbody> | ||
</Table> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button colorScheme="blue" mr={3} onClick={onClose}> | ||
Close | ||
</Button> | ||
<Button | ||
colorScheme="green" | ||
onClick={() => VisitTraining(data.id)} // Pass a function reference | ||
> | ||
<LinkIcon className="w-4 h-4 mr-3" /> | ||
Visit Training Page | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default Detailed_Training_Modal; |
167 changes: 167 additions & 0 deletions
167
frontend/src/components/Detailed_Workout_Modal.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,167 @@ | ||
import React from 'react'; | ||
import { | ||
Modal, | ||
ModalOverlay, | ||
ModalContent, | ||
ModalHeader, | ||
ModalFooter, | ||
ModalBody, | ||
ModalCloseButton, | ||
Button, | ||
Table, | ||
Thead, | ||
Tbody, | ||
Tr, | ||
Th, | ||
Td, | ||
UnorderedList, | ||
ListItem, | ||
VStack, | ||
HStack, | ||
Tag, | ||
TagLabel | ||
} from '@chakra-ui/react'; | ||
|
||
const Detailed_Workout_Modal = ({ isOpen, onClose, data, weekNumber, workoutNumber }) => { | ||
// Fetch the workout details for the specified week and workout number | ||
const getWorkoutByNumber = (weekNumber, workoutNumber) => { | ||
const week = data?.weeks?.find(week => week.weekNumber === weekNumber); | ||
return week?.workouts?.find(workout => workout.workoutNumber === workoutNumber); | ||
}; | ||
|
||
const current_workout = getWorkoutByNumber(weekNumber, workoutNumber); | ||
|
||
if (!current_workout) { | ||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose} size="full"> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader>Workout Details Not Found</ModalHeader> | ||
<ModalCloseButton /> | ||
<ModalBody> | ||
<p>No data available for the selected workout.</p> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button colorScheme="blue" onClick={onClose}> | ||
Close | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
} | ||
|
||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose} size="full"> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader>{data.title} | Week {weekNumber} | Workout {workoutNumber} Detailed Description</ModalHeader> | ||
<ModalCloseButton /> | ||
<ModalBody overflowX="auto"> | ||
<Table variant="striped" size="lg" width="100%"> | ||
<Thead> | ||
<Tr> | ||
<Th>Exercise Name</Th> | ||
<Th>Exercise Gif</Th> | ||
<Th>Instructions</Th> | ||
<Th>Exercise Tags</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
{current_workout.workoutExercises.map((ex) => { | ||
const exerciseDetails = ex.exercise; | ||
|
||
return ( | ||
<Tr key={ex.exerciseNumber}> | ||
{/* Exercise Name */} | ||
<Td> | ||
<VStack align="start"> | ||
<strong>{exerciseDetails?.name || 'N/A'}</strong> | ||
<span>Sets: {ex.sets}</span> | ||
<span>Reps: {ex.repetitions}</span> | ||
</VStack> | ||
</Td> | ||
|
||
{/* Exercise Gif */} | ||
<Td> | ||
{exerciseDetails?.gifUrl ? ( | ||
<img | ||
src={exerciseDetails.gifUrl} | ||
alt={exerciseDetails.name || 'Exercise Gif'} | ||
style={{ | ||
width: '200px', | ||
height: '200px', | ||
objectFit: 'cover' | ||
}} | ||
/> | ||
) : ( | ||
'No Image Available' | ||
)} | ||
</Td> | ||
|
||
{/* Instructions */} | ||
<Td> | ||
<UnorderedList spacing={2}> | ||
{exerciseDetails?.instructions?.length ? ( | ||
exerciseDetails.instructions.map((instruction, index) => ( | ||
<ListItem key={index}>{instruction}</ListItem> | ||
)) | ||
) : ( | ||
<ListItem>No Instructions Available</ListItem> | ||
)} | ||
</UnorderedList> | ||
</Td> | ||
|
||
{/* Exercise Tags */} | ||
<Td> | ||
<VStack align="start" spacing={2}> | ||
{exerciseDetails?.bodyPart && ( | ||
<HStack> | ||
<Tag colorScheme="blue"> | ||
<TagLabel>Body Part: {exerciseDetails.bodyPart}</TagLabel> | ||
</Tag> | ||
</HStack> | ||
)} | ||
{exerciseDetails?.targetMuscle && ( | ||
<HStack> | ||
<Tag colorScheme="green"> | ||
<TagLabel>Target Muscle: {exerciseDetails.targetMuscle}</TagLabel> | ||
</Tag> | ||
</HStack> | ||
)} | ||
{exerciseDetails?.equipment && ( | ||
<HStack> | ||
<Tag colorScheme="purple"> | ||
<TagLabel>Equipment: {exerciseDetails.equipment}</TagLabel> | ||
</Tag> | ||
</HStack> | ||
)} | ||
{exerciseDetails?.secondaryMuscles?.length > 0 && ( | ||
<HStack> | ||
<Tag colorScheme="orange"> | ||
<TagLabel> | ||
Secondary Muscles: {exerciseDetails.secondaryMuscles.join(', ')} | ||
</TagLabel> | ||
</Tag> | ||
</HStack> | ||
)} | ||
</VStack> | ||
</Td> | ||
</Tr> | ||
); | ||
})} | ||
</Tbody> | ||
</Table> | ||
</ModalBody> | ||
|
||
<ModalFooter> | ||
<Button colorScheme="blue" mr={3} onClick={onClose}> | ||
Close | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default Detailed_Workout_Modal; |
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.