Skip to content

Commit

Permalink
small change
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdelmouzahir committed Jul 5, 2024
1 parent a1968a7 commit c88150f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/auth/loginRestaurant/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const sign_in = () => {
setLoginError("");
setEmail("");
setPassword("");
setLoading(false);
//setLoading(false);
})
.catch((err) => {
setLoading(false);
Expand Down
2 changes: 1 addition & 1 deletion app/auth/sign-in/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const sign_in = () => {
setEmail("");
setPassword("");
setLoginError("");
setLoading(false);
//setLoading(false);
})
.catch((err) => {
setLoading(false);
Expand Down
9 changes: 6 additions & 3 deletions app/sait-staff/login/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 });
Expand All @@ -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");
Expand Down

0 comments on commit c88150f

Please sign in to comment.