diff --git a/app/auth/loginRestaurant/page.js b/app/auth/loginRestaurant/page.js index d0350ae..f16b12f 100644 --- a/app/auth/loginRestaurant/page.js +++ b/app/auth/loginRestaurant/page.js @@ -38,7 +38,7 @@ const sign_in = () => { setLoginError(""); setEmail(""); setPassword(""); - setLoading(false); + //setLoading(false); }) .catch((err) => { setLoading(false); diff --git a/app/auth/sign-in/page.js b/app/auth/sign-in/page.js index b7ceeb9..e2c76d9 100644 --- a/app/auth/sign-in/page.js +++ b/app/auth/sign-in/page.js @@ -29,7 +29,7 @@ const sign_in = () => { setEmail(""); setPassword(""); setLoginError(""); - setLoading(false); + //setLoading(false); }) .catch((err) => { setLoading(false); diff --git a/app/sait-staff/login/page.js b/app/sait-staff/login/page.js index a457933..c977e91 100644 --- a/app/sait-staff/login/page.js +++ b/app/sait-staff/login/page.js @@ -32,15 +32,16 @@ const SignIn = () => { const user = auth.currentUser; if (user) { const uid = user.uid; - console.log('user ',uid) const q = query(collection(db, "saitStaff"), where("uid", "==", uid)); const querySnapshot = await getDocs(q); const employeeData = querySnapshot.docs.map((doc) => doc.data().name); + console.log('name: ',employeeData); if (!employeeData.empty) { const saitStaffData = employeeData[0]; const name = saitStaffData || "SAIT Staff"; // Use default name if 'name' is not available setSaitStaffName(name); + console.log("user name: ",name) } else { console.log("No SAIT Staff data found for current user"); setSaitStaffName("SAIT Staff"); // Set default name @@ -57,6 +58,7 @@ const SignIn = () => { try { const userCredential = await signInWithEmailAndPassword(email, password); const user = userCredential.user; + console.log(user); // Update display name with SAIT Staff name await updateProfile(user, { displayName: saitStaffName }); @@ -65,11 +67,12 @@ const SignIn = () => { sessionStorage.setItem("name", saitStaffName); sessionStorage.setItem("email", user.email || ""); // Store the user's email sessionStorage.setItem("uid", user.uid || ""); // Store the user's UID - router.push("/sait-staff"); // Redirect after successful sign-in + console.log(saitStaffName); setEmail(""); setPassword(""); setLoginError(""); - // setLoading(false); + //setLoading(false); + router.push("/sait-staff"); // Redirect after successful sign-in } catch (error) { setLoading(false); setLoginError("Invalid email or password");