|
1 | 1 | import { Menu as MenuIcon } from "@mui/icons-material";
|
2 | 2 | import { AppBar as MuiAppBar, Box, Button, Divider, IconButton, Toolbar } from "@mui/material";
|
3 | 3 | import { styled } from "@mui/material/styles";
|
| 4 | +import { signOut } from "firebase/auth"; |
4 | 5 | import React from "react";
|
5 | 6 | import { ErrorBoundary } from "react-error-boundary";
|
6 | 7 | import { useDispatch, useSelector } from "react-redux";
|
7 | 8 | import { useNavigate } from "react-router-dom";
|
8 | 9 |
|
9 | 10 | import { firebaseApi } from "../../services/firebaseApi";
|
10 | 11 | import { tcApi } from "../../services/tcApi";
|
| 12 | +import { setAuthUserIsReady } from "../../slices/auth"; |
11 | 13 | import { setDrawerOpen } from "../../slices/system";
|
| 14 | +import Firebase from "../../utils/Firebase"; |
12 | 15 | import { drawerWidth } from "../../utils/const";
|
13 | 16 |
|
14 | 17 | import { AppFallback } from "./AppFallback";
|
@@ -46,9 +49,16 @@ export function AppBar() {
|
46 | 49 | const handleLogout = () => {
|
47 | 50 | dispatch(firebaseApi.util.resetApiState()); // reset RTKQ
|
48 | 51 | dispatch(tcApi.util.resetApiState()); // reset RTKQ
|
49 |
| - navigate("/login", { |
50 |
| - state: { message: "Logged out successfully.", from: null, search: null }, |
51 |
| - }); |
| 52 | + dispatch(setAuthUserIsReady(false)); |
| 53 | + signOut(Firebase.getAuth()) |
| 54 | + .then(() => { |
| 55 | + navigate("/login", { |
| 56 | + state: { message: "Logged out successfully.", from: null, search: null }, |
| 57 | + }); |
| 58 | + }) |
| 59 | + .catch((error) => { |
| 60 | + console.error(error); |
| 61 | + }); |
52 | 62 | };
|
53 | 63 |
|
54 | 64 | return (
|
|
0 commit comments