├── public
├── robots.txt
├── favicon.ico
├── manifest.json
└── index.html
├── src
├── assets
│ ├── icons
│ │ ├── gym.png
│ │ ├── target.png
│ │ ├── body-part.png
│ │ ├── equipment.png
│ │ ├── left-arrow.png
│ │ └── right-arrow.png
│ └── images
│ │ ├── Logo.png
│ │ ├── Logo-1.png
│ │ └── banner.png
├── index.js
├── components
│ ├── Loader.js
│ ├── Footer.js
│ ├── ExerciseCard.js
│ ├── Navbar.js
│ ├── SimilarExercises.js
│ ├── BodyPart.js
│ ├── HeroBanner.js
│ ├── ExerciseVideos.js
│ ├── HorizontalScrollBar.js
│ ├── Detail.js
│ ├── Exercises.js
│ └── SearchExercises.js
├── App.js
├── utils
│ └── fetchData.js
├── pages
│ ├── Home.js
│ └── ExerciseDetail.js
└── App.css
├── .gitignore
├── package.json
└── README.md
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prince-Codemon/Gym-Exercise-Website/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/src/assets/icons/gym.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prince-Codemon/Gym-Exercise-Website/HEAD/src/assets/icons/gym.png
--------------------------------------------------------------------------------
/src/assets/images/Logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prince-Codemon/Gym-Exercise-Website/HEAD/src/assets/images/Logo.png
--------------------------------------------------------------------------------
/src/assets/icons/target.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prince-Codemon/Gym-Exercise-Website/HEAD/src/assets/icons/target.png
--------------------------------------------------------------------------------
/src/assets/images/Logo-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prince-Codemon/Gym-Exercise-Website/HEAD/src/assets/images/Logo-1.png
--------------------------------------------------------------------------------
/src/assets/images/banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prince-Codemon/Gym-Exercise-Website/HEAD/src/assets/images/banner.png
--------------------------------------------------------------------------------
/src/assets/icons/body-part.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prince-Codemon/Gym-Exercise-Website/HEAD/src/assets/icons/body-part.png
--------------------------------------------------------------------------------
/src/assets/icons/equipment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prince-Codemon/Gym-Exercise-Website/HEAD/src/assets/icons/equipment.png
--------------------------------------------------------------------------------
/src/assets/icons/left-arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prince-Codemon/Gym-Exercise-Website/HEAD/src/assets/icons/left-arrow.png
--------------------------------------------------------------------------------
/src/assets/icons/right-arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Prince-Codemon/Gym-Exercise-Website/HEAD/src/assets/icons/right-arrow.png
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom/client";
3 | import App from "./App";
4 | import {BrowserRouter} from 'react-router-dom'
5 | const root = ReactDOM.createRoot(document.getElementById('root'));
6 |
7 | root.render(
8 |
9 |
10 |
11 | )
--------------------------------------------------------------------------------
/src/components/Loader.js:
--------------------------------------------------------------------------------
1 | import { Stack } from '@mui/material'
2 | import React from 'react'
3 | import { InfinitySpin } from 'react-loader-spinner'
4 |
5 |
6 | const Loader = () => {
7 | return (
8 |
9 |
10 |
11 | )
12 | }
13 |
14 | export default Loader
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Route, Routes } from "react-router-dom";
3 | import { Box } from "@mui/material";
4 | import "./App.css";
5 | import Navbar from "./components/Navbar";
6 | import ExerciseDetail from "./pages/ExerciseDetail";
7 | import Home from "./pages/Home";
8 | import Footer from "./components/Footer";
9 | const App = () => {
10 | return (
11 |
12 |
13 |
14 | } />
15 | } />
16 |
17 |
18 |
19 | );
20 | };
21 |
22 | export default App;
23 |
--------------------------------------------------------------------------------
/src/utils/fetchData.js:
--------------------------------------------------------------------------------
1 | export const exerciseOptions = {
2 | method: "GET",
3 | // url: "https://exercisedb.p.rapidapi.com/exercises/bodyPartList",
4 | headers: {
5 | "X-RapidAPI-Key": process.env.REACT_APP_RAPID_API_KEY,
6 | "X-RapidAPI-Host": "exercisedb.p.rapidapi.com",
7 | },
8 | };
9 | export const youtubeOptions = {
10 | method: "GET",
11 | url: "https://youtube-search-and-download.p.rapidapi.com/video/related",
12 | headers: {
13 | "X-RapidAPI-Key": process.env.REACT_APP_RAPID_API_KEY,
14 | "X-RapidAPI-Host": "youtube-search-and-download.p.rapidapi.com",
15 | },
16 | };
17 | export const fetchData= async(url, options)=>{
18 | const response = await fetch(url,options)
19 | const data = await response.json()
20 | return data;
21 | }
--------------------------------------------------------------------------------
/src/pages/Home.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { useState } from 'react'
3 | import { Box } from '@mui/material'
4 | import { HeroBanner } from '../components/HeroBanner'
5 | import SearchExercises from '../components/SearchExercises'
6 | import Exercises from '../components/Exercises'
7 | const Home = () => {
8 | const [exercises, setExercises] = useState([]);
9 | const [bodyPart ,setBodyPart] = useState('all')
10 | return (
11 |
12 |
13 |
18 |
23 |
24 | );
25 | }
26 |
27 | export default Home
--------------------------------------------------------------------------------
/src/components/Footer.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Box, Stack, Typography } from "@mui/material";
3 | import Logo from "../assets/images/Logo.png";
4 | const Footer = () => {
5 | return (
6 |
7 |
8 |
9 |
10 | Made with ❤️ by{" "}
11 | Prince Codemon
12 |
13 |
14 | Credit and love to ❤️🔥 Javascript Mastery
15 |
16 |
17 |
18 | );
19 | };
20 |
21 | export default Footer;
22 |
--------------------------------------------------------------------------------
/src/components/ExerciseCard.js:
--------------------------------------------------------------------------------
1 | import { Button , Stack, Typography} from '@mui/material'
2 | import React from 'react'
3 | import { Link } from 'react-router-dom'
4 |
5 |
6 | const ExerciseCard = ({exercise}) => {
7 | return (
8 |
9 |
10 |
11 |
17 |
23 |
24 |
25 | {exercise.name}
26 |
27 |
28 | )
29 | }
30 |
31 | export default ExerciseCard
--------------------------------------------------------------------------------
/src/components/Navbar.js:
--------------------------------------------------------------------------------
1 | import { Stack } from '@mui/material'
2 | import React from 'react'
3 | import { Link } from 'react-router-dom'
4 |
5 | import Logo from '../assets/images/Logo.png'
6 | const Navbar = () => {
7 | return (
8 |
9 |
10 |
15 |
16 |
17 |
25 | Home
26 |
27 |
31 | Exercises
32 |
33 |
34 |
35 | );
36 | }
37 |
38 | export default Navbar
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
14 |
15 |
17 |
18 |
19 |
20 | Gym Exercise
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/components/SimilarExercises.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { Box, Stack, Typography } from '@mui/material'
3 | import HorizontalScrollBar from '../components/HorizontalScrollBar'
4 | import Loader from './Loader'
5 | const SimilarExercises = ({equipmentExercises, targetMuscleExercises}) => {
6 | return (
7 |
8 |
9 | Exercise that target the same muscle group
10 |
11 |
12 | {targetMuscleExercises.length ? :}
13 |
14 |
15 | Exercise that use the same equipment
16 |
17 |
18 | {equipmentExercises.length ? :}
19 |
20 |
21 | );
22 | }
23 |
24 | export default SimilarExercises
--------------------------------------------------------------------------------
/src/components/BodyPart.js:
--------------------------------------------------------------------------------
1 | import { Stack, Typography } from "@mui/material";
2 | import { borderTop } from "@mui/system";
3 | import React from "react";
4 | import Icon from "../assets/icons/gym.png";
5 | const BodyPart = ({ item, setBodyPart, bodyPart }) => {
6 | return (
7 | {setBodyPart(item)
23 | window.scrollTo({top:1800, left:100, behaviour:'smooth'})
24 | }}
25 |
26 | >
27 |
32 |
33 | {item}
34 |
35 |
36 | );
37 | };
38 |
39 | export default BodyPart;
40 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gymwebsite",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@emotion/react": "^11.9.0",
7 | "@emotion/styled": "^11.8.1",
8 | "@mui/icons-material": "^5.6.1",
9 | "@mui/material": "^5.6.1",
10 | "@testing-library/jest-dom": "^5.16.4",
11 | "@testing-library/react": "^13.3.0",
12 | "@testing-library/user-event": "^13.5.0",
13 | "react": "^18.2.0",
14 | "react-dom": "^18.2.0",
15 | "react-horizontal-scrolling-menu": "^2.7.1",
16 | "react-loader-spinner": "^6.0.0-0",
17 | "react-router-dom": "^6.3.0",
18 | "react-scripts": "5.0.1",
19 | "web-vitals": "^2.1.4"
20 | },
21 | "scripts": {
22 | "start": "react-scripts start",
23 | "build": "react-scripts build",
24 | "test": "react-scripts test",
25 | "eject": "react-scripts eject"
26 | },
27 | "eslintConfig": {
28 | "extends": [
29 | "react-app",
30 | "react-app/jest"
31 | ]
32 | },
33 | "browserslist": {
34 | "production": [
35 | ">0.2%",
36 | "not dead",
37 | "not op_mini all"
38 | ],
39 | "development": [
40 | "last 1 chrome version",
41 | "last 1 firefox version",
42 | "last 1 safari version"
43 | ]
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/components/HeroBanner.js:
--------------------------------------------------------------------------------
1 | import { Box,Stack, Typography, Button } from '@mui/material'
2 | import React from 'react'
3 | import HeroBannerImage from '../assets/images/banner.png'
4 | export const HeroBanner = () => {
5 | return (
6 |
10 |
11 | Fitness Club
12 |
13 |
16 | Sweat, Smile
and Repeat
17 |
18 |
19 | Check out the most effective exerciese
20 |
21 |
24 |
26 | Exercise
27 |
28 |
29 |
30 |
31 | )
32 | }
33 |
--------------------------------------------------------------------------------
/src/components/ExerciseVideos.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { Typography, Box, Stack } from '@mui/material'
3 | const ExerciseVideos = ({name, exerciseVideos}) => {
4 | if(!exerciseVideos.length){
5 | return 'Loading...'
6 | }
7 | return (
8 |
9 |
10 | Watch {name} exercise
11 |
12 |
14 | {exerciseVideos?.slice(0,3).map((item,index)=>(
15 |
16 |
17 |
18 |
19 | {item.video.title}
20 |
21 |
22 | {item.video.channelName}
23 |
24 |
25 |
26 | )
27 |
28 | )}
29 |
30 |
31 | );
32 | }
33 |
34 | export default ExerciseVideos
--------------------------------------------------------------------------------
/src/components/HorizontalScrollBar.js:
--------------------------------------------------------------------------------
1 |
2 | import React, { useContext } from "react";
3 | import BodyPart from './BodyPart'
4 | import { ScrollMenu, VisibilityContext } from 'react-horizontal-scrolling-menu'
5 | import { Box, Typography } from "@mui/material";
6 | import ExerciseCard from '../components/ExerciseCard'
7 | import RightArrowIcon from "../assets/icons/right-arrow.png";
8 | import LeftArrowIcon from "../assets/icons/left-arrow.png";
9 |
10 | const LeftArrow = () => {
11 | const { scrollPrev } = useContext(VisibilityContext);
12 |
13 | return (
14 | scrollPrev()} className="right-arrow">
15 |
16 |
17 | );
18 | };
19 |
20 | const RightArrow = () => {
21 | const { scrollNext } = useContext(VisibilityContext);
22 |
23 | return (
24 | scrollNext()} className="left-arrow">
25 |
26 |
27 | );
28 | };
29 |
30 | const HorizontalScrollBar = ({data, setBodyPart, bodyPart, isBodyParts}) => {
31 | return (
32 |
33 | {data.map((item) => (
34 |
40 | {isBodyParts ? : }
41 |
42 | ))}
43 |
44 | );
45 | }
46 |
47 | export default HorizontalScrollBar
--------------------------------------------------------------------------------
/src/components/Detail.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Stack, Typography, Button } from "@mui/material";
3 | import BodyPartImage from "../assets/icons/body-part.png";
4 | import TargetImage from "../assets/icons/target.png";
5 | import EquipmentImage from "../assets/icons/equipment.png";
6 | const Detail = ({ exerciseDetail }) => {
7 | const { bodyPart, gifUrl, name, target, equipment } = exerciseDetail;
8 | const extraDetail = [
9 | { icon: BodyPartImage, name: bodyPart },
10 | { icon: TargetImage, name: target },
11 | { icon: EquipmentImage, name: equipment },
12 | ];
13 | return (
14 |
18 |
19 |
20 | {name}
21 |
22 | Exercises keep you strong. {name}
23 | is one of the best exercises for your {target}. It will help you
24 | improve your mood and gain energy.
25 |
26 | {extraDetail.map((item, index) =>
27 | (
28 |
42 |
43 | {item.name}
44 |
45 | )
46 | )}
47 |
48 |
49 | );
50 | };
51 |
52 | export default Detail;
53 |
--------------------------------------------------------------------------------
/src/pages/ExerciseDetail.js:
--------------------------------------------------------------------------------
1 | import { Box } from '@mui/material'
2 | import React,{useState, useEffect} from 'react'
3 | import {useParams} from 'react-router-dom'
4 | import Detail from '../components/Detail'
5 | import ExerciseVideos from '../components/ExerciseVideos'
6 | import SimilarExercises from '../components/SimilarExercises'
7 |
8 | import {fetchData, exerciseOptions, youtubeOptions} from '../utils/fetchData'
9 |
10 | const ExerciseDetail = () => {
11 | const [exerciseDetail, setExerciseDetail] = useState({})
12 | const [exerciseVideos, setExerciseVideos] = useState([])
13 | const [targetMuscleExercises, setTargetMuscleExercises] = useState([])
14 | const [equipmentExercises, setEquipmentExercises] = useState([])
15 |
16 | const {id} = useParams()
17 | useEffect(()=>{
18 | const fetchExercisesData = async ()=>{
19 | const exerciseDbUrl = "https://exercisedb.p.rapidapi.com";
20 | const youtubeSearchUrl = "https://youtube-search-and-download.p.rapidapi.com";
21 |
22 | const exerciseDetailData=await fetchData(`${exerciseDbUrl}/exercises/exercise/${id}`, exerciseOptions)
23 | setExerciseDetail(exerciseDetailData)
24 | const exerciseVideosData = await fetchData(`${youtubeSearchUrl}/search?query=${exerciseDetailData.name}`, youtubeOptions)
25 | setExerciseVideos(exerciseVideosData.contents)
26 | const targetMuscleExerciseData = await fetchData(
27 | `${exerciseDbUrl}/exercises/target/${exerciseDetailData.target}`,
28 | exerciseOptions
29 | );
30 | setTargetMuscleExercises(targetMuscleExerciseData)
31 | const equipmentExerciseData = await fetchData(
32 | `${exerciseDbUrl}/exercises/equipment/${exerciseDetailData.equipment}`,
33 | exerciseOptions
34 | );
35 | setEquipmentExercises(equipmentExerciseData)
36 | }
37 | fetchExercisesData()
38 | },[id])
39 | return (
40 |
41 |
42 |
43 |
44 |
45 | )
46 | }
47 |
48 | export default ExerciseDetail
--------------------------------------------------------------------------------
/src/components/Exercises.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import { Box, Typography, Stack, Pagination } from "@mui/material";
3 |
4 | import { exerciseOptions, fetchData } from "../utils/fetchData";
5 | import ExerciseCard from "./ExerciseCard";
6 | const Exercises = ({ setExercises, bodyPart, exercises }) => {
7 | const [currentPage, setCurrentPage] = useState(1);
8 | const exercisesPerPage = 9;
9 | const indexOfLastExercise = currentPage * exercisesPerPage;
10 | const indexOfFirstExercise = indexOfLastExercise - exercisesPerPage;
11 | const currentExercises = exercises.slice(
12 | indexOfFirstExercise,
13 | indexOfLastExercise
14 | );
15 | const paginate = (e, value) => {
16 | setCurrentPage(value);
17 | window.scrollTo({ top: 1800, behavior: "smooth" });
18 | };
19 |
20 | useEffect(() => {
21 | const fetchExercisesData = async () => {
22 | let exercisesData = [];
23 | if (bodyPart === "all") {
24 | exercisesData = await fetchData(
25 | "https://exercisedb.p.rapidapi.com/exercises",
26 | exerciseOptions
27 | );
28 | } else {
29 | exercisesData = await fetchData(
30 | `https://exercisedb.p.rapidapi.com/exercises/bodyPart/${bodyPart}`,
31 | exerciseOptions
32 | );
33 | }
34 | setExercises(exercisesData);
35 | };
36 | fetchExercisesData();
37 | }, [bodyPart]);
38 | return (
39 |
47 |
48 | Showing Results
49 |
50 |
56 | {currentExercises.map((exercise, index) => {
57 | return ;
58 | })}
59 |
60 |
61 | {exercises.length > 9 && (
62 |
71 | )}
72 |
73 |
74 | );
75 | };
76 |
77 | export default Exercises;
78 |
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: 'Josefin Sans';
3 | background-color: #FFFAFB;
4 | }
5 |
6 | * {
7 | padding: 0px;
8 | margin: 0px;
9 | box-sizing: border-box;
10 |
11 | }
12 |
13 | ::-webkit-scrollbar {
14 | width: 0px;
15 | }
16 |
17 | .right-arrow,
18 | .left-arrow {
19 | cursor: pointer;
20 | background: transparent;
21 | outline: none;
22 | border: none;
23 | display: flex;
24 | justify-content: center;
25 | align-items: center;
26 | color: #FF2625;
27 | font-size: 25px;
28 | border-radius: 4px;
29 | position: absolute;
30 | bottom: -20px;
31 | right: 80px;
32 | transform: scale(1, 1);
33 | transition: 0.3s all ease-in-out;
34 | }
35 |
36 | .right-arrow {
37 | right: 140px;
38 | }
39 |
40 | .right-arrow:hover,
41 | .left-arrow:hover {
42 | transform: scale(1.3, 1.3);
43 | }
44 |
45 | .react-horizontal-scrolling-menu--wrapper {
46 | width: 100%;
47 | display: flex;
48 | flex-wrap: wrap;
49 | }
50 |
51 | .detail-image {
52 | width: 729px;
53 | height: 742px;
54 | }
55 |
56 | .hero-banner-img {
57 | position: absolute;
58 | right: 40px;
59 | top: 0px;
60 | width: 700px;
61 | height: 900px;
62 | margin-top: -330px;
63 |
64 | }
65 |
66 | .exercise-card {
67 | width: 400px;
68 | height: 445px;
69 | background: #fff;
70 | border-top: 4px solid #FF2625;
71 | border-bottom-left-radius: 20px;
72 | text-decoration: none;
73 | display: flex;
74 | justify-content: space-between;
75 | flex-direction: column;
76 | padding-bottom: 10px;
77 | transform: scale(1, 1);
78 | transition: 0.3s all ease-in-out;
79 | }
80 |
81 | .exercise-card img {
82 | height: 326px;
83 | }
84 |
85 | .bodyPart-card {
86 | transform: scale(1, 1);
87 | transition: 0.3s all ease-in-out;
88 | }
89 |
90 | .exercise-card:hover,
91 | .bodyPart-card:hover {
92 | transform: scale(1.1, 1.1);
93 | }
94 |
95 | .search-btn:hover {
96 | color: #FF2625 !important;
97 | border: 1px solid #FF2625 !important;
98 | }
99 |
100 | .exercise-video {
101 | display: flex;
102 | flex-direction: column;
103 | gap: 24px;
104 | width: 387px;
105 | height: 381px;
106 | text-decoration: none;
107 | }
108 |
109 | @media screen and (max-width:1200px) {
110 | .detail-image {
111 | width: 300px;
112 | height: 300px;
113 | }
114 |
115 |
116 | .react-horizontal-scrolling-menu--scroll-container {
117 | width: 500px;
118 | }
119 |
120 | .left-arrow,
121 | .right-arrow {
122 | position: static !important;
123 | }
124 |
125 | .hero-banner-img {
126 | display: none;
127 | }
128 |
129 | .exercise-card {
130 | width: 320px;
131 | }
132 |
133 | .exercise-video {
134 | width: 320px;
135 | height: 300px;
136 | }
137 |
138 | }
139 |
140 | @media screen and (max-width:400px) {
141 | .exercise-card {
142 | width: 280px;
143 | }
144 | }
--------------------------------------------------------------------------------
/src/components/SearchExercises.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from "react";
2 | import { Box, Stack, Typography, Button, TextField } from "@mui/material";
3 | import { fetchData, exerciseOptions } from "../utils/fetchData";
4 | import HorizontalScrollBar from "./HorizontalScrollBar";
5 |
6 | const SearchExercises = ({setExercises, bodyPart, setBodyPart}) => {
7 | const [search, setSearch] = useState("");
8 |
9 | const [bodyParts, setBodyParts] = useState([]);
10 | useEffect(() => {
11 | const fetchExercisesData = async () => {
12 | const bodyPartsData = await fetchData(
13 | "https://exercisedb.p.rapidapi.com/exercises/bodyPartList",
14 | exerciseOptions
15 | );
16 | setBodyParts(["all", ...bodyPartsData]);
17 | };
18 | fetchExercisesData()
19 | }, []);
20 | const handleSearch = async () => {
21 | if (search) {
22 | const exercisesData = await fetchData(
23 | "https://exercisedb.p.rapidapi.com/exercises",
24 | exerciseOptions
25 | );
26 | const searchedExercises = exercisesData.filter(
27 | (exercise) =>
28 | exercise.name.toLowerCase().includes(search) ||
29 | exercise.target.toLowerCase().includes(search) ||
30 | exercise.equipment.toLowerCase().includes(search) ||
31 | exercise.bodyPart.toLowerCase().includes(search)
32 | );
33 | setSearch("");
34 | setExercises(searchedExercises);
35 | }
36 | };
37 | return (
38 |
39 |
45 | Awesome Exercises you
46 | Should Know
47 |
48 |
49 | {
62 | setSearch(e.target.value.toLowerCase());
63 | }}
64 | placeholder="Search Exercises"
65 | type="text"
66 | />
67 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | );
98 | };
99 |
100 | export default SearchExercises;
101 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `npm start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13 |
14 | The page will reload when you make changes.\
15 | You may also see any lint errors in the console.
16 |
17 | ### `npm test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `npm run build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `npm run eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35 |
36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39 |
40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `npm run build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------