From 5fc046024666af3021efe7f9fe136d74f06d22a8 Mon Sep 17 00:00:00 2001 From: Hunardeep Singh Date: Mon, 8 Jul 2024 20:28:35 -0600 Subject: [PATCH] Hunar (#53) * Add folder for student register issue: There was a router problem for student register resolve: always make page.js for route just separate them by making different folders. * database * - Created useContext for user (uid) - Added service folder with functions to read and write data from the database - Added authentication for student/homepage and student/information - Updated student/login page to fix email and password authentication issues * starting login page * login page design * signup page complete * adding colors * file change * forget password * add modal * add conditions * login page * add posst function for menu and restaurant details * meging with main * adding restaurant information page * fetching and adding data for restaurants * merging from origin * merge from orign * adding emails status in database * add and create function for adding new email with active status add and create function for getting email names where active status is true make changes in register page to check that email is in database for register * chengin import sttement * adding terms condition * adding logos facility * merge from master * update database sait-staff * adding search option * commit * connecting sait-staff with database * merging form master * changes on sait * mege from master to origin * changing restaurant info table * adding data to database * updating cards * adding logc for increase and decrease arrow * adding databse changes * updating datasbe function to getting student information * adding authentication for restaurants * changing Searching bar * adding search bar in sait-staff * updating restaurant login page * adding update,delete and change password features * adding fuctionality of deleting user's information from database including user data and restaurant menu, delete data from storage and from authentication * update edit functionallity in sait-staff and add delete functionality in restaurant * add add functionality for admins * Hunar (#46) * Add folder for student register issue: There was a router problem for student register resolve: always make page.js for route just separate them by making different folders. * database * - Created useContext for user (uid) - Added service folder with functions to read and write data from the database - Added authentication for student/homepage and student/information - Updated student/login page to fix email and password authentication issues * starting login page * login page design * signup page complete * adding colors * file change * forget password * add modal * add conditions * login page * add posst function for menu and restaurant details * meging with main * adding restaurant information page * fetching and adding data for restaurants * merging from origin * merge from orign * adding emails status in database * add and create function for adding new email with active status add and create function for getting email names where active status is true make changes in register page to check that email is in database for register * chengin import sttement * adding terms condition * adding logos facility * merge from master * update database sait-staff * adding search option * commit * connecting sait-staff with database * merging form master * changes on sait * mege from master to origin * changing restaurant info table * adding data to database * updating cards * adding logc for increase and decrease arrow * adding databse changes * updating datasbe function to getting student information * adding authentication for restaurants * changing Searching bar * adding search bar in sait-staff * updating restaurant login page * adding update,delete and change password features * adding fuctionality of deleting user's information from database including user data and restaurant menu, delete data from storage and from authentication --------- Co-authored-by: Abdel Mouzahir <123598139+Abdelmouzahir@users.noreply.github.com> * trying to show username in saitstaff * console log * small change * remove azure * adding loading animation * loading in all login pages * trying to fetch the name * fetch data in login * comment to hunar * problem solved mentioned by abdel * updatinf sait-login * add feature of edit and update active state * add search functionality in sait-staff * add feature of updating password and delete account * small change * add profil picture in saitadmin * approuval * add profile page for sait-staff and resolve the problem related sait-staff login --------- Co-authored-by: Abdel Mouzahir <123598139+Abdelmouzahir@users.noreply.github.com> Co-authored-by: abdel mouzahir --- Components/UserGreeting.js | 40 ++++-- app/auth/sign-in/page.js | 2 +- app/page.js | 88 ++++++++++-- app/sait-staff/RDashboard/Edit.js | 1 + app/sait-staff/SDashboard/Edit.js | 1 + app/sait-staff/login/page.js | 16 +-- app/sait-staff/overviewDash/Edit.js | 3 +- app/sait-staff/overviewDash/index.js | 3 + app/sait-staff/overviewDash/table.js | 2 +- app/sait-staff/page.js | 82 +++++++---- app/sait-staff/settingS/index.js | 6 +- app/sait-staff/settingS/userProfile/page.js | 129 ++++++++++++++++++ package-lock.json | 58 +------- public/assets/images/UserDefaultSaitStaff.png | Bin 0 -> 67043 bytes 14 files changed, 303 insertions(+), 128 deletions(-) create mode 100644 app/sait-staff/settingS/userProfile/page.js create mode 100644 public/assets/images/UserDefaultSaitStaff.png diff --git a/Components/UserGreeting.js b/Components/UserGreeting.js index 767cd66..bc51a91 100644 --- a/Components/UserGreeting.js +++ b/Components/UserGreeting.js @@ -1,33 +1,43 @@ import { useEffect, useState } from "react"; import { AiOutlineUser } from "react-icons/ai"; +import { useUserAuth } from "@/services/utils"; +import { getSaitDataByUser } from "@/services/GetRequest/getRequest"; -const UserGreeting = () => { +const UserGreeting = ({setActiveTab}) => { + const { user } = useUserAuth(); + const [userData, setUserData] = useState(null); const [userName, setUserName] = useState("User"); const [email, setEmail] = useState(""); - const [uid, setUid] = useState(""); const [userImage, setUserImage] = useState(""); + async function fetchSaitStaffUserInformation() { + const data = await getSaitDataByUser(user); + setUserData(data); + console.log(data); + } + useEffect(() => { - // Ensure this runs only on the client-side - if (typeof window !== "undefined") { - const name = sessionStorage.getItem("name") || "User"; - const userEmail = sessionStorage.getItem("email") || ""; - const userUid = sessionStorage.getItem("uid") || ""; - const userImage = sessionStorage.getItem("imageUrl") || ""; + if (!user==false && user){ + fetchSaitStaffUserInformation(); + } + }, [user]); - setUserName(name); - setEmail(userEmail); - setUid(userUid); - setUserImage(userImage); + useEffect(() => { + if(userData){ + setUserName(userData[0].name); + setEmail(userData[0].email); + setUserImage(userData[0].imageUrl); } - }, []); + }, [userData]); + + useEffect(() => {console.log(userImage)}, [userName, email, userImage]); return ( -
+
{setActiveTab("setting")}}>
User Image
diff --git a/app/auth/sign-in/page.js b/app/auth/sign-in/page.js index e2c76d9..5c672ab 100644 --- a/app/auth/sign-in/page.js +++ b/app/auth/sign-in/page.js @@ -5,7 +5,7 @@ import { auth } from "@/app/firebase/config"; import { useRouter } from "next/navigation"; import Link from "next/link"; import { sendPasswordResetEmail } from "firebase/auth"; -import Modal from "@/components/Modal"; +import Modal from "@/Components/Modal"; import { BiSolidCommentError } from "react-icons/bi"; import Loading from "@/app/loading"; diff --git a/app/page.js b/app/page.js index 6226aaf..3570b7f 100644 --- a/app/page.js +++ b/app/page.js @@ -1,14 +1,13 @@ 'use client' import Header from "./main-component/layout/header/header"; import Footer from "./main-component/layout/footer/footer"; -import { Button } from "@/components/ui/button"; -import Modal from "@/components/Modal"; +import { Button } from "@/Components/ui/button"; +import Modal from "@/Components/Modal"; import {motion} from "framer-motion"; -import { Card, CardContent } from "/components/ui/card"; -import { Avatar, AvatarFallback } from "@/components/ui/avatar"; +import { Card, CardContent } from "/Components/ui/card"; +import { Avatar, AvatarFallback } from "@/Components/ui/avatar"; import { useState } from "react"; -import LearnMore from "@/components/LearnMore"; -import Reviews from "@/components/reviews"; +import LearnMore from "@/Components/LearnMore"; export default function Home() { @@ -24,7 +23,7 @@ const [showModal, setShowModal] = useState(false);
-
- +
+
+
+
+ Student Testimonials +
+

What Our Users Say

+

+ Hear from our satisfied students about how our app has helped them discover delicious and affordable + meals near their campus. +

+
+
+
+ + +
+ + @username + JS + +
+

Jessica Smith

+

University of California, Berkeley

+
+
+

+ "This app has been a game-changer for me as a busy student. I love being able to discover new + restaurants with discounts and save money on delicious meals. It's made eating out so much more + affordable." +

+
+
+ + +
+ + @username + MR + +
+

Michael Rodriguez

+

University of Texas, Austin

+
+
+

+ "As a student, I'm always looking for ways to save money, and this app has been a lifesaver. The + discounts and deals have helped me enjoy delicious meals without breaking the bank. I highly + recommend it to all my friends." +

+
+
+ + +
+ + @username + EM + +
+

Emily Martinez

+

University of Washington, Seattle

+
+
+

+ "I love how this app connects me with local restaurants that offer discounts for students. It's + helped me discover so many new and delicious places to eat, and the community aspect is really + special. I feel like I'm part of a network of students who are all looking to save money and enjoy + great food." +

+
+
+
diff --git a/app/sait-staff/RDashboard/Edit.js b/app/sait-staff/RDashboard/Edit.js index c7b5bf9..ac411c9 100644 --- a/app/sait-staff/RDashboard/Edit.js +++ b/app/sait-staff/RDashboard/Edit.js @@ -74,6 +74,7 @@ const Edit = ({ restaurants, selectedRestaurant, setRestaurants, setIsEditing, g value={email} // onChange={(e) => setEmail(e.target.value)} className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none sm:text-sm cursor-not-allowed bg-black/20" + readOnly={true} />
diff --git a/app/sait-staff/SDashboard/Edit.js b/app/sait-staff/SDashboard/Edit.js index b7cc568..c0a42a1 100644 --- a/app/sait-staff/SDashboard/Edit.js +++ b/app/sait-staff/SDashboard/Edit.js @@ -101,6 +101,7 @@ const Edit = ({ selectedStudent, setIsEditing }) => { value={email} // onChange={(e) => setEmail(e.target.value)} className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none sm:text-sm cursor-not-allowed bg-black/20" + readOnly={true} />
diff --git a/app/sait-staff/login/page.js b/app/sait-staff/login/page.js index 8fb2828..255fce3 100644 --- a/app/sait-staff/login/page.js +++ b/app/sait-staff/login/page.js @@ -2,12 +2,11 @@ import React, { Fragment, useState, useEffect } from "react"; import { useSignInWithEmailAndPassword } from "react-firebase-hooks/auth"; import { auth, db } from "@/app/firebase/config"; -import { updateProfile } from "firebase/auth"; import { collection, query, where, getDocs } from "firebase/firestore"; import { useRouter } from "next/navigation"; import { sendPasswordResetEmail } from "firebase/auth"; import { AiOutlineUser } from "react-icons/ai"; -import Modal from "@/components/Modal"; +import Modal from "@/Components/Modal"; import { BiSolidCommentError } from "react-icons/bi"; import Loading from "@/app/loading"; @@ -62,18 +61,7 @@ const SignIn = () => { const handleSignIn = async () => { setLoading(true); try { - const userCredential = await signInWithEmailAndPassword(email, password); - const user = userCredential.user; - - // Update display name with SAIT Staff name - await updateProfile(user, { displayName: saitStaffName , photoURL : saitStaffimg}); - //console.log('img ',saitStaffimg) - - sessionStorage.setItem("user", true); - sessionStorage.setItem("name", saitStaffName); - sessionStorage.setItem("email", user.email || ""); // Store the user's email - sessionStorage.setItem("uid", user.uid || ""); // Store the user's UID - sessionStorage.setItem("imageUrl", saitStaffimg|| ""); // Store the user's photo URL + await signInWithEmailAndPassword(email, password); router.push("/sait-staff"); // Redirect after successful sign-in setEmail(""); setPassword(""); diff --git a/app/sait-staff/overviewDash/Edit.js b/app/sait-staff/overviewDash/Edit.js index 085e117..54f026e 100644 --- a/app/sait-staff/overviewDash/Edit.js +++ b/app/sait-staff/overviewDash/Edit.js @@ -89,11 +89,12 @@ const Edit = ({ employeeData, setIsEditing, getData, userData }) => { value={email} // onChange={(e) => setEmail(e.target.value)} className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none sm:text-sm cursor-not-allowed bg-black/20" + readOnly={true} />