Added clearing monitor state
This commit is contained in:
1 parent
7d7b155d45
commit
3c8de47c5f
2 files changed
+12
-2
No files matched your search
@@ -14,6 +14,8 @@ import MenuItem from "@mui/material/MenuItem";
|
|||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import ChevronDown from "../../assets/Images/Icon-chevron-down.png";
|
import ChevronDown from "../../assets/Images/Icon-chevron-down.png";
|
||||||
import { clearAuthState } from "../../Features/Auth/authSlice";
|
import { clearAuthState } from "../../Features/Auth/authSlice";
|
||||||
|
import { clearMonitorState } from "../../Features/Monitors/monitorsSlice";
|
||||||
|
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
@@ -52,6 +54,7 @@ function NavBar() {
|
|||||||
const logout = () => {
|
const logout = () => {
|
||||||
// Clear auth state
|
// Clear auth state
|
||||||
dispatch(clearAuthState());
|
dispatch(clearAuthState());
|
||||||
|
dispatch(clearMonitorState());
|
||||||
navigate("/");
|
navigate("/");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,14 @@ export const getMonitorsByUserId = createAsyncThunk(
|
|||||||
const monitorsSlice = createSlice({
|
const monitorsSlice = createSlice({
|
||||||
name: "monitors",
|
name: "monitors",
|
||||||
initialState,
|
initialState,
|
||||||
reducers: {},
|
reducers: {
|
||||||
|
clearMonitorState: (state) => {
|
||||||
|
state.isLoading = false;
|
||||||
|
state.monitors = [];
|
||||||
|
state.success = null;
|
||||||
|
state.msg = null;
|
||||||
|
},
|
||||||
|
},
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
builder
|
builder
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
@@ -86,6 +93,6 @@ const monitorsSlice = createSlice({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const { setMonitors } = monitorsSlice.actions;
|
export const { setMonitors, clearMonitorState } = monitorsSlice.actions;
|
||||||
|
|
||||||
export default monitorsSlice.reducer;
|
export default monitorsSlice.reducer;
|
||||||
Reference in new issue
Block a user