Changed auth slice to status slice to better reflect onboarding state tracking

This commit is contained in:
Keannu Christian Bernasol 2023-07-06 21:13:02 +08:00
parent 90f227a2c0
commit b30bbb62df
6 changed files with 38 additions and 35 deletions

View file

@ -1,10 +1,10 @@
import { configureStore } from "@reduxjs/toolkit";
import AuthReducer from "../slices/AuthSlice/AuthSlice";
import StatusReducer from "../slices/StatusSlice/StatusSlice";
import UserReducer from "../slices/UserSlice/UserSlice";
const store = configureStore({
reducer: {
auth: AuthReducer,
status: StatusReducer,
user: UserReducer,
},
});

View file

@ -1,23 +0,0 @@
import { createSlice } from "@reduxjs/toolkit";
export const AuthSlice = createSlice({
name: "Auth",
initialState: {
creds: {
logged_in: false,
},
},
reducers: {
login: (state) => {
state.creds.logged_in = true;
},
logout: (state) => {
state.creds.logged_in = false;
},
},
});
// Action creators are generated for each case reducer function
export const { login, logout } = AuthSlice.actions;
export default AuthSlice.reducer;

View file

@ -0,0 +1,28 @@
import { createSlice } from "@reduxjs/toolkit";
export const StatusSlice = createSlice({
name: "Status",
initialState: {
logged_in: false,
onboarding: false,
},
reducers: {
login: (state) => {
state.logged_in = true;
},
logout: (state) => {
state.logged_in = false;
},
onboard: (state) => {
state.onboarding = true;
},
not_onboard: (state) => {
state.onboarding = false;
},
},
});
// Action creators are generated for each case reducer function
export const { login, logout, onboard, not_onboard } = StatusSlice.actions;
export default StatusSlice.reducer;