From dace2a2b320cb06d548318b1e4829bff3e719830 Mon Sep 17 00:00:00 2001 From: Akhila Sunesh <140897461+AkhilaSunesh@users.noreply.github.com> Date: Sat, 15 Jun 2024 11:13:40 +0530 Subject: [PATCH 01/13] done --- src/components/Navbar.jsx | 160 +++++++++------------ src/pages/Login.jsx | 170 ++++++---------------- src/pages/Signup.jsx | 295 +++++++++++++------------------------- 3 files changed, 209 insertions(+), 416 deletions(-) diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index 437efda..e6e0351 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -5,6 +5,7 @@ import { motion, AnimatePresence, useScroll } from "framer-motion"; import { IoClose } from "react-icons/io5"; import { GiHamburgerMenu } from "react-icons/gi"; import { ThemeContext } from '../themeContext'; + const Navbar = () => { const { theme, toggleTheme } = useContext(ThemeContext); const [isOpen, setIsOpen] = useState(false); @@ -16,109 +17,90 @@ const Navbar = () => { return ( <> - + ); }; @@ -135,11 +117,11 @@ const NavItem = ({ icon, to, children }) => { }; const MobileNavItem = ({ to, children }) => { - let classname = "z-[2] text-gray-300 text-center hover:text-white block px-3 py-2 rounded-md text-xl font-medium "; + const classname = "z-[2] text-gray-300 text-center hover:text-white block px-3 py-2 rounded-md text-xl font-medium "; return ( {children} @@ -152,6 +134,4 @@ const IconAbout = () => ℹī¸; const IconNews = () => 📰; const IconRateUs = () => ⭐; - export default Navbar; - diff --git a/src/pages/Login.jsx b/src/pages/Login.jsx index 9767f7e..00ef4d4 100644 --- a/src/pages/Login.jsx +++ b/src/pages/Login.jsx @@ -1,25 +1,23 @@ - import React, { useState, useEffect } from "react"; - import { AiOutlineEye, AiOutlineEyeInvisible } from "react-icons/ai"; import { Link, useNavigate } from "react-router-dom"; import { toast } from "react-hot-toast"; import axios from "axios"; - import logo from "../assets/logo2.png"; -import Loader from "../components/Loader/Loader"; +import Loader from "../components/Loader/Loader"; // Ensure this path is correct import { useAuth } from "../authContext"; + function Login() { const [formData, setFormData] = useState({ email: "", - accountType : "", + accountType: "", password: "", }); const { checkAuthentication } = useAuth(); const [showPassword, setShowPassword] = useState(false); const [loading, setLoading] = useState(false); - const [rememberMe, setRememberMe] = useState(false); + const [rememberMe, setRememberMe] = useState(false); const navigate = useNavigate(); @@ -41,43 +39,38 @@ function Login() { })); } - function rememberMeHandler(event) { setRememberMe(event.target.checked); + if (!event.target.checked) { + localStorage.removeItem("rememberedEmail"); + } } async function submitHandler(event) { event.preventDefault(); + setLoading(true); - - if(formData.accountType === "User"){ - - const apiUrl = `${process.env.REACT_APP_BASE_URL}/studentLogin`; - // const apiUrl = `http://localhost:4000/api/v1/studentLogin`; - - axios.post(apiUrl , formData) - .then((response)=>{ - toast.success("User Logged in "); - navigate("/home"); - }) - .catch((error)=>{ - toast.error("Failed to login") - }); + if (rememberMe) { + localStorage.setItem("rememberedEmail", formData.email); } - else{ + const apiUrl = + formData.accountType === "User" + ? `${process.env.REACT_APP_BASE_URL}/studentLogin` + : `${process.env.REACT_APP_BASE_URL}/canteenLogin`; - const apiUrl = `${process.env.REACT_APP_BASE_URL}/canteenLogin`; - - axios.post(apiUrl , formData) - .then((response)=>{ - toast.success("User Logged in "); + try { + const response = await axios.post(apiUrl, formData); + toast.success("User Logged in"); + if (formData.accountType === "User") { + navigate("/home"); + } else { navigate(`/section/${response.data.cantId}`); - }) - .catch((error)=>{ - toast.error("Failed to login") - }); - + } + } catch (error) { + toast.error("Failed to login"); + } finally { + setLoading(false); } } @@ -89,9 +82,7 @@ function Login() {
- @@ -108,55 +99,10 @@ function Login() {
- -
- -
- -
- logo -

Connecting You to Your College Canteens

-
- -
-
-
-
- -
- -
- -
- -

Hello Again!

-

Welcome Back

- -
- -
- -
- -

- Hello Again! -

-

- Welcome Back -

- + +

Hello Again!

+

Welcome Back

-
-
setShowPassword((prev) => !prev)} > {showPassword ? ( - - ) : ( + ) : ( + )}
-
-

Forgot Password ?

-
- -
- - setShowPassword((prev) => !prev)} - > - {showPassword ? : } - + Login + + + + Don't have an account? Sign Up + + +
- - - - - Don't have an account? Sign Up - - - - -
- -
+
+ )} + ); } export default Login; - diff --git a/src/pages/Signup.jsx b/src/pages/Signup.jsx index afb10d0..4f1076a 100644 --- a/src/pages/Signup.jsx +++ b/src/pages/Signup.jsx @@ -3,10 +3,10 @@ import { Link, useNavigate } from "react-router-dom"; import { AiOutlineEye, AiOutlineEyeInvisible } from "react-icons/ai"; import { toast } from "react-hot-toast"; import axios from "axios"; -import logo from "../assets/logo2.png" +import logo from "../assets/logo2.png"; import Icon from 'react-icons-kit'; -import { arrows_circle_check } from 'react-icons-kit/linea/arrows_circle_check' -import { arrows_exclamation } from 'react-icons-kit/linea/arrows_exclamation' +import { arrows_circle_check } from 'react-icons-kit/linea/arrows_circle_check'; +import { arrows_exclamation } from 'react-icons-kit/linea/arrows_exclamation'; function Signup() { const [formData, setFormData] = useState({ @@ -19,14 +19,13 @@ function Signup() { }); const [showconfirmPassword, setshowconfirmPassword] = useState(false); - const [showPassword, setShowPassword] = useState(false); const [lowerValidated, setLowerValidated] = useState(false); const [upperValidated, setUpperValidated] = useState(false); const [numberValidated, setNumberValidated] = useState(false); const [specialValidated, setSpecialValidated] = useState(false); const [lengthValidated, setLengthValidated] = useState(false); - + const [loading, setLoading] = useState(false); const navigate = useNavigate(); @@ -34,44 +33,19 @@ function Signup() { const lower = new RegExp('(?=.*[a-z])'); const upper = new RegExp('(?=.*[A-Z])'); const number = new RegExp('(?=.*[0-9])'); - const special = new RegExp('(?=.*[!@#\$%\^&\*])'); - const length = new RegExp('(?=.{8,})') + const special = new RegExp('(?=.*[!@#\\$%\\^&\\*])'); + const length = new RegExp('(?=.{8,})'); const value = event.target.value; - if (lower.test(value)) { - setLowerValidated(true); - } - else { - setLowerValidated(false); - } - if (upper.test(value)) { - setUpperValidated(true); - } - else { - setUpperValidated(false); - } - if (number.test(value)) { - setNumberValidated(true); - } - else { - setNumberValidated(false); - } - if (special.test(value)) { - setSpecialValidated(true); - } - else { - setSpecialValidated(false); - } - if (length.test(value)) { - setLengthValidated(true); - } - else { - setLengthValidated(false); - } + setLowerValidated(lower.test(value)); + setUpperValidated(upper.test(value)); + setNumberValidated(number.test(value)); + setSpecialValidated(special.test(value)); + setLengthValidated(length.test(value)); setFormData((prevData) => ({ ...prevData, - [event.target.name]: event.target.value, + [event.target.name]: value, })); } @@ -82,52 +56,36 @@ function Signup() { })); } - function submitHandler(event) { + async function submitHandler(event) { event.preventDefault(); - console.log("ENV FILE",process.env.REACT_APP_BASE_URL); + console.log("ENV FILE", process.env.REACT_APP_BASE_URL); if (lowerValidated && upperValidated && numberValidated && specialValidated && lengthValidated) { - if (formData.accountType === "User") { + const apiUrl = formData.accountType === "User" + ? `${process.env.REACT_APP_BASE_URL}/studentSignup` + : `${process.env.REACT_APP_BASE_URL}/canteenSignup`; - const apiUrl = `${process.env.REACT_APP_BASE_URL}/studentSignup`; - // const apiUrl = `http://localhost:3000/api/v1/studentSignUp`; - try { - setLoading(true); + try { + setLoading(true); - const response = await axios.post(apiUrl, formData); + const response = await axios.post(apiUrl, formData); - toast.success("Account Created Successfully!"); - navigate("/"); - } catch (error) { - const errorMessage = - error.response?.data?.message || - "Failed to login. Please try again."; - toast.error(errorMessage); - console.log("This is our error ", error); - } finally { - setLoading(false); - } - } else { - const apiUrl = `${process.env.REACT_APP_BASE_URL}/canteenSignup`; - // const apiUrl = `${process.env.REACT_APP_BASE_URL}/canteenSignup`; - - try { - setLoading(true); - - const response = await axios.post(apiUrl, formData); + if (formData.accountType === "Canteen") { const token = response.data.token; - localStorage.setItem("token", token); localStorage.setItem("canteenId", response.data.cantId); - toast.success("Account Created Successfully!"); navigate(`/section/${response.data.cantId}`); - } catch (error) { - toast.error("Failed To Create Account. Please try again."); - console.error(error); - } finally { - setLoading(false); + } else { + navigate("/"); } + toast.success("Account Created Successfully!"); + } catch (error) { + const errorMessage = error.response?.data?.message || "Failed to create account. Please try again."; + toast.error(errorMessage); + console.error("Error:", error); + } finally { + setLoading(false); } } else { toast.error("Password must pass all the criteria"); @@ -135,15 +93,12 @@ function Signup() { } return ( -
+
logo -

- Connecting You to Your College Canteens -

+

Connecting You to Your College Canteens

-
@@ -151,16 +106,9 @@ function Signup() {
-
-

- Hello There! -

-

- Create an Account -

+ +

Hello There!

+

Create an Account

- @@ -224,146 +172,97 @@ function Signup() { value={formData.password} onChange={PasswordChecker} /> + setShowPassword((prev) => !prev)}> + {showPassword ? : } + +
+ +
+ setShowPassword((prev) => !prev)} + onClick={() => setshowconfirmPassword((prev) => !prev)} > - {showPassword ? ( - - ) : ( - - )} + {showconfirmPassword ? : }
- -
- - setshowconfirmPassword((prev) => !prev)} - > - {showconfirmPassword ? ( - - ) : ( - - )} - -
- - + - Already have an account? Login + + Already have an account? Login + - {/* - - Validation Checks for password - - */} - -
+
- {lowerValidated ? ( - - - - ) : ( - - - - )} + + + At least one lowercase letter
- {upperValidated ? ( - - - - ) : ( - - - - )} + + + At least one uppercase letter
- {numberValidated ? ( - - - - ) : ( - - - - )} + + + At least one number
- {specialValidated ? ( - - - - ) : ( - - - - )} + + + At least one special character
- {lengthValidated ? ( - - - - ) : ( - - - - )} + + + At least 8 characters
-
+
); From 38c938ba80d8f96017830e2954edfeb42de2d74a Mon Sep 17 00:00:00 2001 From: Nishant Kaushal <101548649+nishant0708@users.noreply.github.com> Date: Sun, 16 Jun 2024 02:54:34 +0530 Subject: [PATCH 02/13] Fixed all bugs --- server/controllers/Auth.js | 6 - server/server.js | 2 +- src/components/CanteenCard.jsx | 2 +- src/components/Navbar.jsx | 1 + src/pages/Home.jsx | 2 +- src/pages/Login.jsx | 170 +++++++------------------- src/pages/Signup.jsx | 210 ++++++++++++--------------------- 7 files changed, 122 insertions(+), 271 deletions(-) diff --git a/server/controllers/Auth.js b/server/controllers/Auth.js index e3c2b95..cafbd5d 100644 --- a/server/controllers/Auth.js +++ b/server/controllers/Auth.js @@ -3,9 +3,7 @@ const User = require("../models/studentLoginInfo"); const jwt = require("jsonwebtoken"); const Canteen = require("../models/canteenLoginInfo"); const Session = require("../models/session"); -<<<<<<< HEAD const Contact = require('../models/Contact'); -======= const { forgotPasswordToken, verifyToken, @@ -13,7 +11,6 @@ const { findUserById, } = require("../utils/PasswordTokenAndUser"); const nodemailer = require("nodemailer"); ->>>>>>> upstream/main require("dotenv").config(); @@ -445,7 +442,6 @@ exports.changeCanteenPassword = async (req, res) => { }); }; -<<<<<<< HEAD //contactUs @@ -464,7 +460,6 @@ exports.saveContactMessage = async (req, res) => { } }; -======= // verify user for reset password exports.forgotPassword = async (req, res) => { try { @@ -602,4 +597,3 @@ exports.resetPassword = async (req, res) => { res.status(500).json("Some error occurred!"); } }; ->>>>>>> upstream/main diff --git a/server/server.js b/server/server.js index 6836f6c..ab571da 100644 --- a/server/server.js +++ b/server/server.js @@ -2,7 +2,7 @@ const express = require("express"); const app = express(); const cors = require("cors"); var cookieParser = require("cookie-parser"); -const PORT = process.env.PORT || 4000; +const PORT = process.env.PORT || 8000; //originally 4000 tha const cloudinaryConfig = require("./config/cloudinaryConfig"); const contactRoutes = require('./routes/contactRoutes'); const bodyParser = require('body-parser'); diff --git a/src/components/CanteenCard.jsx b/src/components/CanteenCard.jsx index b78a9b7..af60d08 100644 --- a/src/components/CanteenCard.jsx +++ b/src/components/CanteenCard.jsx @@ -41,7 +41,7 @@ const CanteenCard = ({ canteen }) => { {canteen.name} diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index 437efda..bb97a9f 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -117,6 +117,7 @@ const Navbar = () => { )} +
); diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index 33ae514..56bf9f8 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -29,7 +29,7 @@ function Home() { try{ setLoading(true); const getCanteen = await fetch( - `${process.env.REACT_APP_BASE_URL}/api/v1/getcanteen`, + `${process.env.REACT_APP_BASE_URL}/getcanteen`, { method : "GET", headers :{ diff --git a/src/pages/Login.jsx b/src/pages/Login.jsx index 9767f7e..424c9b3 100644 --- a/src/pages/Login.jsx +++ b/src/pages/Login.jsx @@ -1,6 +1,4 @@ - import React, { useState, useEffect } from "react"; - import { AiOutlineEye, AiOutlineEyeInvisible } from "react-icons/ai"; import { Link, useNavigate } from "react-router-dom"; import { toast } from "react-hot-toast"; @@ -9,17 +7,18 @@ import axios from "axios"; import logo from "../assets/logo2.png"; import Loader from "../components/Loader/Loader"; import { useAuth } from "../authContext"; + function Login() { const [formData, setFormData] = useState({ email: "", - accountType : "", + accountType: "", password: "", }); const { checkAuthentication } = useAuth(); const [showPassword, setShowPassword] = useState(false); const [loading, setLoading] = useState(false); - const [rememberMe, setRememberMe] = useState(false); + const [rememberMe, setRememberMe] = useState(false); const navigate = useNavigate(); @@ -41,7 +40,6 @@ function Login() { })); } - function rememberMeHandler(event) { setRememberMe(event.target.checked); } @@ -49,35 +47,30 @@ function Login() { async function submitHandler(event) { event.preventDefault(); + const apiUrl = + formData.accountType === "User" + ? `${process.env.REACT_APP_BASE_URL}/studentLogin` + : `${process.env.REACT_APP_BASE_URL}/canteenLogin`; - if(formData.accountType === "User"){ + try { + const response = await axios.post(apiUrl, formData); + toast.success("User Logged in"); - const apiUrl = `${process.env.REACT_APP_BASE_URL}/studentLogin`; - // const apiUrl = `http://localhost:4000/api/v1/studentLogin`; + if (rememberMe) { + localStorage.setItem("rememberedEmail", formData.email); + } else { + localStorage.removeItem("rememberedEmail"); + } - axios.post(apiUrl , formData) - .then((response)=>{ - toast.success("User Logged in "); + if (formData.accountType === "User") { navigate("/home"); - }) - .catch((error)=>{ - toast.error("Failed to login") - }); - } - - else{ - - const apiUrl = `${process.env.REACT_APP_BASE_URL}/canteenLogin`; - - axios.post(apiUrl , formData) - .then((response)=>{ - toast.success("User Logged in "); + } else { + localStorage.setItem("canteenId",response.data.cantId); + localStorage.setItem("token",response.data.token); navigate(`/section/${response.data.cantId}`); - }) - .catch((error)=>{ - toast.error("Failed to login") - }); - + } + } catch (error) { + toast.error("Failed to login"); } } @@ -89,10 +82,8 @@ function Login() {
-
@@ -108,55 +99,10 @@ function Login() {
- -
- -
- -
- logo -

Connecting You to Your College Canteens

-
- -
-
-
-
- -
- -
- -
- -

Hello Again!

-

Welcome Back

- -
- -
- -
- -

- Hello Again! -

-

- Welcome Back -

- + +

Hello Again!

+

Welcome Back

-
-
setShowPassword((prev) => !prev)} > - {showPassword ? ( - - ) : ( - - )} + {showPassword ? : }
-
-
-

Forgot Password ?

+

Forgot Password?

-
- -
- - setShowPassword((prev) => !prev)} - > - {showPassword ? : } - + Login + + + + Don't have an account? Sign Up + + +
- - - - - Don't have an account? Sign Up - - - - -
- -
+ + )} + ); } export default Login; - diff --git a/src/pages/Signup.jsx b/src/pages/Signup.jsx index afb10d0..f8eac2c 100644 --- a/src/pages/Signup.jsx +++ b/src/pages/Signup.jsx @@ -3,10 +3,10 @@ import { Link, useNavigate } from "react-router-dom"; import { AiOutlineEye, AiOutlineEyeInvisible } from "react-icons/ai"; import { toast } from "react-hot-toast"; import axios from "axios"; -import logo from "../assets/logo2.png" +import logo from "../assets/logo2.png"; import Icon from 'react-icons-kit'; -import { arrows_circle_check } from 'react-icons-kit/linea/arrows_circle_check' -import { arrows_exclamation } from 'react-icons-kit/linea/arrows_exclamation' +import { arrows_circle_check } from 'react-icons-kit/linea/arrows_circle_check'; +import { arrows_exclamation } from 'react-icons-kit/linea/arrows_exclamation'; function Signup() { const [formData, setFormData] = useState({ @@ -18,15 +18,14 @@ function Signup() { confirmPassword: "", }); - const [showconfirmPassword, setshowconfirmPassword] = useState(false); - + const [showConfirmPassword, setShowConfirmPassword] = useState(false); const [showPassword, setShowPassword] = useState(false); const [lowerValidated, setLowerValidated] = useState(false); const [upperValidated, setUpperValidated] = useState(false); const [numberValidated, setNumberValidated] = useState(false); const [specialValidated, setSpecialValidated] = useState(false); const [lengthValidated, setLengthValidated] = useState(false); - + const [loading, setLoading] = useState(false); const navigate = useNavigate(); @@ -35,39 +34,14 @@ function Signup() { const upper = new RegExp('(?=.*[A-Z])'); const number = new RegExp('(?=.*[0-9])'); const special = new RegExp('(?=.*[!@#\$%\^&\*])'); - const length = new RegExp('(?=.{8,})') + const length = new RegExp('(?=.{8,})'); const value = event.target.value; - if (lower.test(value)) { - setLowerValidated(true); - } - else { - setLowerValidated(false); - } - if (upper.test(value)) { - setUpperValidated(true); - } - else { - setUpperValidated(false); - } - if (number.test(value)) { - setNumberValidated(true); - } - else { - setNumberValidated(false); - } - if (special.test(value)) { - setSpecialValidated(true); - } - else { - setSpecialValidated(false); - } - if (length.test(value)) { - setLengthValidated(true); - } - else { - setLengthValidated(false); - } + setLowerValidated(lower.test(value)); + setUpperValidated(upper.test(value)); + setNumberValidated(number.test(value)); + setSpecialValidated(special.test(value)); + setLengthValidated(length.test(value)); setFormData((prevData) => ({ ...prevData, @@ -82,52 +56,35 @@ function Signup() { })); } - function submitHandler(event) { + async function submitHandler(event) { event.preventDefault(); - console.log("ENV FILE",process.env.REACT_APP_BASE_URL); + console.log("ENV FILE", process.env.REACT_APP_BASE_URL); if (lowerValidated && upperValidated && numberValidated && specialValidated && lengthValidated) { - if (formData.accountType === "User") { + const apiUrl = formData.accountType === "User" + ? `${process.env.REACT_APP_BASE_URL}/studentSignup` + : `${process.env.REACT_APP_BASE_URL}/canteenSignup`; - const apiUrl = `${process.env.REACT_APP_BASE_URL}/studentSignup`; - // const apiUrl = `http://localhost:3000/api/v1/studentSignUp`; - try { - setLoading(true); + try { + setLoading(true); - const response = await axios.post(apiUrl, formData); + const response = await axios.post(apiUrl, formData); - toast.success("Account Created Successfully!"); + toast.success("Account Created Successfully!"); + if (formData.accountType === "User") { navigate("/"); - } catch (error) { - const errorMessage = - error.response?.data?.message || - "Failed to login. Please try again."; - toast.error(errorMessage); - console.log("This is our error ", error); - } finally { - setLoading(false); - } - } else { - const apiUrl = `${process.env.REACT_APP_BASE_URL}/canteenSignup`; - // const apiUrl = `${process.env.REACT_APP_BASE_URL}/canteenSignup`; - - try { - setLoading(true); - - const response = await axios.post(apiUrl, formData); + } else { const token = response.data.token; - localStorage.setItem("token", token); localStorage.setItem("canteenId", response.data.cantId); - toast.success("Account Created Successfully!"); navigate(`/section/${response.data.cantId}`); - } catch (error) { - toast.error("Failed To Create Account. Please try again."); - console.error(error); - } finally { - setLoading(false); } - + } catch (error) { + const errorMessage = error.response?.data?.message || "Failed to create account. Please try again."; + toast.error(errorMessage); + console.error(error); + } finally { + setLoading(false); } } else { toast.error("Password must pass all the criteria"); @@ -135,7 +92,7 @@ function Signup() { } return ( -
+
logo @@ -151,10 +108,7 @@ function Signup() {
-
+

Hello There!

@@ -236,47 +190,40 @@ function Signup() {
+
+ + setShowConfirmPassword((prev) => !prev)} + > + {showConfirmPassword ? ( + + ) : ( + + )} + +
-
- - setshowconfirmPassword((prev) => !prev)} - > - {showconfirmPassword ? ( - - ) : ( - - )} - -
- - + Already have an account? Login - {/* - - Validation Checks for password - - */} -
{lowerValidated ? ( @@ -339,31 +286,30 @@ function Signup() { At least 8 characters
-
); From cceea8a822271ba6edde912d9be20f0188a4064e Mon Sep 17 00:00:00 2001 From: Nishant Kaushal <101548649+nishant0708@users.noreply.github.com> Date: Sun, 16 Jun 2024 03:08:37 +0530 Subject: [PATCH 03/13] Fixed bugs --- envexample | 1 + server/envexample | 6 ++++++ server/server.js | 2 +- src/components/ModalForm.jsx | 6 +++--- src/pages/AddFoodItem.jsx | 6 +++--- src/pages/EditProfile.jsx | 4 ++-- src/pages/Foodlist.jsx | 6 +++--- src/pages/MenuPage.jsx | 6 +++--- src/pages/SectionPage.jsx | 2 +- 9 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 envexample create mode 100644 server/envexample diff --git a/envexample b/envexample new file mode 100644 index 0000000..f8d1c7c --- /dev/null +++ b/envexample @@ -0,0 +1 @@ +REACT_APP_BASE_URL="localhost:8000/api/v1" 8000 can be replaced by the server you are running backend on \ No newline at end of file diff --git a/server/envexample b/server/envexample new file mode 100644 index 0000000..f4f26dd --- /dev/null +++ b/server/envexample @@ -0,0 +1,6 @@ +PORT=8000 +DATABASE_URL= +JWT_SECRET= +CLOUDINARY_CLOUD_NAME= +CLOUDINARY_API_KEY= +CLOUDINARY_API_SECRET= diff --git a/server/server.js b/server/server.js index ab571da..6836f6c 100644 --- a/server/server.js +++ b/server/server.js @@ -2,7 +2,7 @@ const express = require("express"); const app = express(); const cors = require("cors"); var cookieParser = require("cookie-parser"); -const PORT = process.env.PORT || 8000; //originally 4000 tha +const PORT = process.env.PORT || 4000; const cloudinaryConfig = require("./config/cloudinaryConfig"); const contactRoutes = require('./routes/contactRoutes'); const bodyParser = require('body-parser'); diff --git a/src/components/ModalForm.jsx b/src/components/ModalForm.jsx index 09ae7d4..d8f9339 100644 --- a/src/components/ModalForm.jsx +++ b/src/components/ModalForm.jsx @@ -60,7 +60,7 @@ const ModalForm = ({ onSubmit , sectionName , canteenData , id}) => { if(sectionName === "Breakfast"){ - const apiUrl = `http://localhost:8000/api/v1/${id}/breakfast/add`; + const apiUrl = `${process.env.REACT_APP_BASE_URL}/${id}/breakfast/add`; axios.post(apiUrl , foodDetails) .then((response)=>{ @@ -75,7 +75,7 @@ const ModalForm = ({ onSubmit , sectionName , canteenData , id}) => { } else if(sectionName === "Lunch"){ - const apiUrl = `http://localhost:8000/api/v1/${id}/lunch/add`; + const apiUrl = `${process.env.REACT_APP_BASE_URL}/${id}/lunch/add`; axios.post(apiUrl , foodDetails) .then((response)=>{ @@ -92,7 +92,7 @@ const ModalForm = ({ onSubmit , sectionName , canteenData , id}) => { } else{ - const apiUrl = `http://localhost:8000/api/v1/${id}/dinner/add`; + const apiUrl = `${process.env.REACT_APP_BASE_URL}/${id}/dinner/add`; axios.post(apiUrl , foodDetails) .then((response)=>{ diff --git a/src/pages/AddFoodItem.jsx b/src/pages/AddFoodItem.jsx index 7e25280..a897bd2 100644 --- a/src/pages/AddFoodItem.jsx +++ b/src/pages/AddFoodItem.jsx @@ -35,13 +35,13 @@ function AddFoodItem() { switch (mealType) { case "Breakfast": - apiUrl = `http://localhost:8000/api/v1/${canteenId}/breakfast/add`; + apiUrl = `${process.env.REACT_APP_BASE_URL}/${canteenId}/breakfast/add`; break; case "Lunch": - apiUrl = `http://localhost:8000/api/v1/${canteenId}/lunch/add`; + apiUrl = `${process.env.REACT_APP_BASE_URL}/${canteenId}/lunch/add`; break; case "Dinner": - apiUrl = `http://localhost:8000/api/v1/${canteenId}/dinner/add`; + apiUrl = `${process.env.REACT_APP_BASE_URL}/${canteenId}/dinner/add`; break; default: toast.error("Please select a meal type."); diff --git a/src/pages/EditProfile.jsx b/src/pages/EditProfile.jsx index aa5192d..fcf7445 100644 --- a/src/pages/EditProfile.jsx +++ b/src/pages/EditProfile.jsx @@ -17,7 +17,7 @@ const EditProfile = () => { const fetchCanteenData = async () => { try { - const getCanteen = await fetch(`http://localhost:8000/api/v1/getcanteen`, { + const getCanteen = await fetch(`${process.env.REACT_APP_BASE_URL}/getcanteen`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -69,7 +69,7 @@ const EditProfile = () => { const handleSubmit = async (e) => { e.preventDefault(); try { - const response = await fetch(`http://localhost:8000/api/v1/${_id}/update`, { + const response = await fetch(`${process.env.REACT_APP_BASE_URL}/${_id}/update`, { method: 'PUT', headers: { 'Content-Type': 'application/json', diff --git a/src/pages/Foodlist.jsx b/src/pages/Foodlist.jsx index cda6993..0ae3d4e 100644 --- a/src/pages/Foodlist.jsx +++ b/src/pages/Foodlist.jsx @@ -22,7 +22,7 @@ const Foodlist = () => { try { setLoading(true); const response = await fetch( - `http://localhost:8000/api/v1/${_id}/${mealType}`, + `${process.env.REACT_APP_BASE_URL}/${_id}/${mealType}`, { method: "GET", headers: { @@ -48,7 +48,7 @@ const Foodlist = () => { } await axios.delete( - `http://localhost:8000/api/v1/${_id}/${mealType}/remove`, + `${process.env.REACT_APP_BASE_URL}/${_id}/${mealType}/remove`, { headers: { "Content-Type": "application/json", @@ -84,7 +84,7 @@ const Foodlist = () => { } await axios.put( - `http://localhost:8000/api/v1/${_id}/${currentDish.mealType}/updateitem`, + `${process.env.REACT_APP_BASE_URL}/${_id}/${currentDish.mealType}/updateitem`, { dishId: currentDish._id, dish: updatedDish, diff --git a/src/pages/MenuPage.jsx b/src/pages/MenuPage.jsx index 4a20eb9..dc267d3 100644 --- a/src/pages/MenuPage.jsx +++ b/src/pages/MenuPage.jsx @@ -20,7 +20,7 @@ function MenuPage() { try { setLoading(true); const getBreakfast = await fetch( - `http://localhost:8000/api/v1/${_id}/breakfast`, + `${process.env.REACT_APP_BASE_URL}/${_id}/breakfast`, { method: "GET", headers: { @@ -42,7 +42,7 @@ function MenuPage() { try { setLoading(true); const getLunch = await fetch( - `http://localhost:8000/api/v1/${_id}/lunch`, + `${process.env.REACT_APP_BASE_URL}/${_id}/lunch`, { method: "GET", headers: { @@ -64,7 +64,7 @@ function MenuPage() { try { setLoading(true); const getDinner = await fetch( - `http://localhost:8000/api/v1/${_id}/dinner`, + `${process.env.REACT_APP_BASE_URL}/${_id}/dinner`, { method: "GET", headers: { diff --git a/src/pages/SectionPage.jsx b/src/pages/SectionPage.jsx index a9ed459..97bd0bc 100644 --- a/src/pages/SectionPage.jsx +++ b/src/pages/SectionPage.jsx @@ -25,7 +25,7 @@ const SectionPage = () => { try { setLoading(true); const getCanteen = await fetch( - `http://localhost:8000/api/v1/getcanteen`, + `${process.env.REACT_APP_BASE_URL}/getcanteen`, { method: "GET", headers: { From 67a32360fdc4c9f01e567d0c16c5d0c45146b6fc Mon Sep 17 00:00:00 2001 From: Akhila Sunesh <140897461+AkhilaSunesh@users.noreply.github.com> Date: Sun, 16 Jun 2024 10:06:31 +0530 Subject: [PATCH 04/13] done --- .github/pull_request_template.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 8dbe145..0345064 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,33 +1,32 @@ Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. - Fixes # (issue) - ## Type of change -Please give a X on it which is applicable +Please mark with an X the type that applies: - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) -- [ ] Refactor Code -- [ ] A documentation update -- [ ] Others(mentioned in the issue number) +- [ ] Refactor code +- [ ] Documentation update +- [ ] Other (mentioned in the issue number) # How Has This Been Tested? -Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration +Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce them. Please also list any relevant details for your test configuration. + +**_Test A: Describe here_** -**_Test A Describe here_** +**_Test B: Describe here (if required)_** -**_Test B Describe here (if Requred)_** +# Screenshots and Videos -# Screenshorts and Vedios: +Please provide screenshots and videos of the changes you made. -give screenshorts and vedio of the changes you made +# Checklist -# Checklist: -give a X on it which is applicable +Please mark with an X the items that apply: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code From 76b05eeb95dd0a04216f3c8324e035eb34785f28 Mon Sep 17 00:00:00 2001 From: Sailaja Adapa Date: Sun, 16 Jun 2024 16:42:03 +0530 Subject: [PATCH 05/13] Enhanced Rate Us Page --- src/pages/Rateus.jsx | 84 ++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 62 deletions(-) diff --git a/src/pages/Rateus.jsx b/src/pages/Rateus.jsx index 3791e4d..bbc4eb7 100644 --- a/src/pages/Rateus.jsx +++ b/src/pages/Rateus.jsx @@ -1,16 +1,13 @@ -import React, { useState, useRef, useEffect } from 'react'; +import React, { useState } from 'react'; import Footer from "../components/Footer"; import Navbar from "../components/Navbar"; -import { ToastContainer, toast } from 'react-toastify'; -import 'react-toastify/dist/ReactToastify.css'; const RateUs = () => { - const [rating, setRating] = useState(0); + const [rating, setRating] = useState(''); const [feedback, setFeedback] = useState(''); - const handleRatingChange = (value) => { - setRating(value); - updateStars(value); + const handleRatingClick = (emoji) => { + setRating(emoji); }; const handleFeedbackChange = (event) => { @@ -18,69 +15,43 @@ const RateUs = () => { }; const handleSubmit = () => { - if (rating > 0 && feedback.trim() !== '') { - toast.success("Thanks for Your Feedback :)"); + if (rating && feedback.trim() !== '') { console.log('Rating:', rating); console.log('Feedback:', feedback); } else { - toast.error("Please Fill All The Details :("); + console.log("Please Fill All The Details :("); } }; - const updateStars = (rating) => { - const stars = document.querySelectorAll('.stars input[type="radio"]'); - stars.forEach((star, index) => { - if (index < rating) { - star.checked = true; - star.nextElementSibling.style.color = '#ffcf00'; - } else { - star.checked = false; - star.nextElementSibling.style.color = '#ccc'; - } - }); - }; - return ( -
-

Rate Our Website

-
- {[1, 2, 3, 4, 5].map((value) => ( - - handleRatingChange(value)} - className="hidden" - /> - - +

Rate Our Website

+
+ {['đŸ˜ĸ', '😡', '😐', '😊', '🤩'].map((emoji) => ( + handleRatingClick(emoji)} + > + {emoji} + ))}