├── .gitignore
├── README.md
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── frontendwireframe.png
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
└── robots.txt
└── src
├── App.css
├── App.js
├── App.test.js
├── Pages
├── Form.js
├── Home.js
├── InfoPage.js
├── Login.js
└── Profile.js
├── Routes.js
├── components
├── Comments.js
├── FoodDisplay.js
├── FoodSearch.js
└── NavBar.js
├── index.css
├── index.js
├── reportWebVitals.js
├── setupTests.js
└── styles
├── FoodForm.module.css
├── FoodInfo.module.css
├── Navbar.module.css
└── Signup.module.css
/.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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Howedible Frontend
2 |
3 | This is the The backend github repository
4 | https://github.com/han18/Backend.git
5 |
6 | Frontend deployment link
7 | https://elegant-starburst-9dc3a6.netlify.app/
8 | ## Description of the project:
9 |
10 | HowEdible is a recipe search app that contains recipes from all over the world with images and cooking instructions.
11 |
12 | ## future implementations of this project
13 |
14 | Convert the app into a food social network where people who are passionate about cooking can create channels and upload short videos of their recipes.
15 |
16 | ## List of installed dependencies
17 |
18 | react-router-dom,
19 | bootstrap,
20 | axios
21 |
22 | ## Source References
23 |
24 | Form: sign up
25 | https://youtu.be/adMD46G5BXU?si=uPdY0tBqmz9D0jf-
26 | https://blog.logrocket.com/how-to-make-http-requests-like-a-pro-with-axios/
27 |
28 | ## FoodSearch Component:
29 |
30 | api: www.themealdb.com/api/json/v1/1/search.php?f=a
31 |
32 | ## YT:
33 |
34 | https://youtu.be/HYSspU4XhC4?si=yegOMb-UetBGi893
35 | https://youtu.be/KRJvlxhLXxk?si=wNeW-FviPtoBl3cm
36 | https://youtu.be/oU2c_02YaME?si=0w42wwgzfwVQBMDZ
37 |
38 | Routing:
39 | https://www.youtube.com/watch?v=SLfhMt5OUPI
40 |
41 | Redirect users to pages in the profile
42 | https://www.geeksforgeeks.org/how-to-redirect-to-a-relative-url-in-javascript/
43 |
44 | ## Sources to use the useNavigate and local storage and
45 |
46 | https://www.youtube.com/watch?v=NvNJtZaDt8E
47 | https://reactrouter.com/en/main/hooks/use-navigate
48 | https://www.youtube.com/watch?v=rWfhwW9forg
49 | https://stackoverflow.com/questions/60688411/assign-local-storage-to-react-state-react-hooks
50 | https://www.youtube.com/watch?v=fTP2gi7e3k8
51 |
52 | ## Using the Crud operation to create comments source
53 |
54 | https://www.youtube.com/watch?v=XYrNkTkx8Uc
55 |
56 | ## optional chaining
57 |
58 | https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
59 | https://www.youtube.com/watch?v=K7rHYyf6E0g
60 | https://javascript.info/optional-chaining
61 |
62 | ## css reference and sources
63 |
64 | https://www.youtube.com/watch?v=ZawAwPYrxGA
65 | https://create-react-app.dev/docs/adding-a-css-modules-stylesheet/
66 |
67 | ## This is the frontend wire-frame of the app
68 |
69 |
70 |
71 | ## This is the frontend structure of the app
72 |
73 |
74 |
75 | \***\*\*\*\*\***\*\*\***\*\*\*\*\***\*\*\***\*\*\*\*\***\*\*\***\*\*\*\*\***\*\*\*\*\***\*\*\*\*\***\*\*\***\*\*\*\*\***\*\*\***\*\*\*\*\***\*\*\***\*\*\*\*\***
76 |
77 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
78 |
79 | ## Available Scripts
80 |
81 | In the project directory, you can run:
82 |
83 | ### `npm start`
84 |
85 | Runs the app in the development mode.\
86 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
87 |
88 | The page will reload when you make changes.\
89 | You may also see any lint errors in the console.
90 |
91 | ### `npm test`
92 |
93 | Launches the test runner in the interactive watch mode.\
94 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
95 |
96 | ### `npm run build`
97 |
98 | Builds the app for production to the `build` folder.\
99 | It correctly bundles React in production mode and optimizes the build for the best performance.
100 |
101 | The build is minified and the filenames include the hashes.\
102 | Your app is ready to be deployed!
103 |
104 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
105 |
106 | ### `npm run eject`
107 |
108 | **Note: this is a one-way operation. Once you `eject`, you can't go back!**
109 |
110 | 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.
111 |
112 | 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.
113 |
114 | 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.
115 |
116 | ## Learn More
117 |
118 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
119 |
120 | To learn React, check out the [React documentation](https://reactjs.org/).
121 |
122 | ### Code Splitting
123 |
124 | 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)
125 |
126 | ### Analyzing the Bundle Size
127 |
128 | 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)
129 |
130 | ### Making a Progressive Web App
131 |
132 | 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)
133 |
134 | ### Advanced Configuration
135 |
136 | 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)
137 |
138 | ### Deployment
139 |
140 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
141 |
142 | ### `npm run build` fails to minify
143 |
144 | 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)
145 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "frontend",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.17.0",
7 | "@testing-library/react": "^13.4.0",
8 | "@testing-library/user-event": "^13.5.0",
9 | "axios": "^1.6.7",
10 | "bootstrap": "^5.3.2",
11 | "react": "^18.2.0",
12 | "react-bootstrap": "^2.10.0",
13 | "react-dom": "^18.2.0",
14 | "react-router-dom": "^6.22.0",
15 | "react-scripts": "5.0.1",
16 | "web-vitals": "^2.1.4"
17 | },
18 | "scripts": {
19 | "start": "react-scripts start",
20 | "build": "react-scripts build",
21 | "test": "react-scripts test",
22 | "eject": "react-scripts eject"
23 | },
24 | "eslintConfig": {
25 | "extends": [
26 | "react-app",
27 | "react-app/jest"
28 | ]
29 | },
30 | "browserslist": {
31 | "production": [
32 | ">0.2%",
33 | "not dead",
34 | "not op_mini all"
35 | ],
36 | "development": [
37 | "last 1 chrome version",
38 | "last 1 firefox version",
39 | "last 1 safari version"
40 | ]
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/han18/Frontend/b7a3ed6576eec0a8bb93861a9249d802a36ad92a/public/favicon.ico
--------------------------------------------------------------------------------
/public/frontendwireframe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/han18/Frontend/b7a3ed6576eec0a8bb93861a9249d802a36ad92a/public/frontendwireframe.png
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
57 |
--------------------------------------------------------------------------------
/src/Pages/Login.js:
--------------------------------------------------------------------------------
1 | // this file is the form reflects the users collection schema
2 | import "../styles/Signup.module.css";
3 |
4 | import axios from "axios";
5 | import { useState } from "react";
6 | import { useNavigate } from "react-router-dom";
7 |
8 | const Login = ({ setUser }) => {
9 | const [formData, setFormData] = useState({
10 | email: "",
11 | password: "",
12 | });
13 |
14 | const navigate = useNavigate();
15 |
16 | const handleChange = (e) => {
17 | setFormData({ ...formData, [e.target.name]: e.target.value });
18 | };
19 |
20 | const handleSubmit = async (e) => {
21 | e.preventDefault();
22 |
23 | try {
24 | const response = await axios.post(
25 | "https://howedible-backend.onrender.com/api/users/login",
26 | formData
27 | );
28 | console.log(response?.data);
29 |
30 | // If success it saves user information to the local storag sets the state, and redirects the user to the profile
31 | if (response.data?.user?._id) {
32 | localStorage.setItem("user", JSON.stringify(response.data?.user));
33 | setUser(response.data?.user);
34 |
35 | // taking the user id from the response and redirecting them to the profile page
36 | // window.location.href = `/profile/${response.data.user._id}`;
37 | navigate("/profile");
38 | } else {
39 | console.error("Failed to login");
40 | alert("Incorrect Email or Password.");
41 | }
42 | } catch (error) {
43 | console.error("Error:", error);
44 | }
45 | };
46 |
47 | return (
48 |
49 |
79 |
80 | );
81 | };
82 |
83 | export default Login;
84 |
--------------------------------------------------------------------------------
/src/Pages/Profile.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { useNavigate } from "react-router-dom";
3 |
4 | const Profile = ({ user }) => {
5 | const navigate = useNavigate();
6 |
7 | // the optional chaining ?. if for some reason the id property is not present in the response object, then no error will be given.
8 | // if user is logged in display the welcome message
9 | if (!user?.email) {
10 | // if email does exist in the user object
11 | return navigate("/");
12 | }
13 |
14 | return (
15 |
16 |
20 |
Welcome, {user.first_name}
21 |
Username: {user.username}
22 |
First Name: {user.first_name}
23 |
Last Name: {user.last_name}
24 |
Email: {user.email}
25 |
26 |
{user.first_name}, we are excited for you to try new recipes!