diff --git a/server/controllers/canteenController.js b/server/controllers/canteenController.js index 08479f3..697e48e 100644 --- a/server/controllers/canteenController.js +++ b/server/controllers/canteenController.js @@ -45,10 +45,10 @@ const getBreakfast = async (req, res, next) => { res.status(500).json({ success: false, error: error.message }); } }; - catch(error){ - res.status(500).json({success : false , error : error}); - } -} +// catch(error){ +// res.status(500).json({success : false , error : error}); +// } +// } const feedback = async (req, res) => { const { canteenId, feedback, rating } = req.body; const token = req.body.studentId; // This is the token @@ -120,12 +120,12 @@ const canteenFeedbackRender = async (req, res) => { } }; -const getLunch = async(req , res , next) =>{ +// const getLunch = async(req , res , next) =>{ - try{ - const id = req.params.id; +// try{ +// const id = req.params.id; - const lunchData = await Lunch.find({ canteen: id }).select("dish").select("dishId").exec(); +// const lunchData = await Lunch.find({ canteen: id }).select("dish").select("dishId").exec(); const getLunch = async (req, res, next) => { try { diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index 45a9a8b..e1c35b8 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -1,5 +1,6 @@ -import React, { useState, useContext, useEffect } from "react"; -import { Link } from "react-router-dom"; +import React, { useState, useContext } from "react"; +import { Link, useNavigate } from "react-router-dom"; + import logo from "../assets/logo2.png"; import { motion, AnimatePresence, useScroll } from "framer-motion"; import { IoClose } from "react-icons/io5"; @@ -9,9 +10,10 @@ import { jwtDecode } from "jwt-decode"; import { useAuth } from "../authContext"; const Navbar = () => { - + const navigate = useNavigate(); + const canteenId = localStorage.getItem("canteenId"); const { logout} = useAuth(); - // const [canteenId, setCanteenId] = useState(null); + const { theme, toggleTheme } = useContext(ThemeContext); const [isOpen, setIsOpen] = useState(false); const { scrollYProgress } = useScroll(); @@ -35,6 +37,12 @@ const Navbar = () => { setIsOpen(!isOpen); }; + const handleLogout = () => { + localStorage.removeItem('usertoken'); + navigate('/') + } + + return ( <> + + {isOpen && ( + +
+ Home + About us + News + Contact + RateUs + {/* Conditionally render "My Canteen" button */} + {canteenId && ( + My Canteen + )} + + + +
+
+ )} +
+ + + ); }; diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index 8bd886f..cadc481 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -10,10 +10,6 @@ import Footer from "../components/Footer"; import FloatBtn from "../components/FloatBtn/FloatBtn"; import { useAuth } from "../authContext"; import { useNavigate } from "react-router-dom"; -<<<<<<< Updated upstream -======= -import Reviews from "../components/Feedback"; ->>>>>>> Stashed changes function Home() { const navigate = useNavigate(); @@ -140,12 +136,6 @@ function Home() {
-<<<<<<< Updated upstream -======= -
- -
->>>>>>> Stashed changes