Added clearing monitor state

This commit is contained in:
Alex Holliday committed 2024-06-24 12:00:49 -07:00
1 parent 7d7b155d45
commit 3c8de47c5f
2 files changed
+12 -2

No files matched your search

+3
View File
@@ -14,6 +14,8 @@ import MenuItem from "@mui/material/MenuItem";
import { useTheme } from "@mui/material/styles";
import ChevronDown from "../../assets/Images/Icon-chevron-down.png";
import { clearAuthState } from "../../Features/Auth/authSlice";
import { clearMonitorState } from "../../Features/Monitors/monitorsSlice";
import { useDispatch } from "react-redux";
import { useNavigate } from "react-router-dom";
@@ -52,6 +54,7 @@ function NavBar() {
const logout = () => {
// Clear auth state
dispatch(clearAuthState());
dispatch(clearMonitorState());
navigate("/");
};
@@ -46,7 +46,14 @@ export const getMonitorsByUserId = createAsyncThunk(
const monitorsSlice = createSlice({
name: "monitors",
initialState,
reducers: {},
reducers: {
clearMonitorState: (state) => {
state.isLoading = false;
state.monitors = [];
state.success = null;
state.msg = null;
},
},
extraReducers: (builder) => {
builder
// *****************************************************
@@ -86,6 +93,6 @@ const monitorsSlice = createSlice({
},
});
export const { setMonitors } = monitorsSlice.actions;
export const { setMonitors, clearMonitorState } = monitorsSlice.actions;
export default monitorsSlice.reducer;