diff options
author | 2024-07-09 20:20:38 +0100 | |
---|---|---|
committer | 2024-07-10 01:56:38 +0100 | |
commit | 5c8125a283fbb6c0ffd69b36e43ff655fc7ce8aa (patch) | |
tree | 5e472dc0ece0d14d2e73a8f2b7c4dd64dcdb190a /src | |
parent | Add @reduxjs/toolkit and react-redux packages (diff) |
Add new redux stores and slices for authorization state
Diffstat (limited to 'src')
-rw-r--r-- | src/slices/authorization.ts | 20 | ||||
-rw-r--r-- | src/store.ts | 21 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/slices/authorization.ts b/src/slices/authorization.ts new file mode 100644 index 0000000..c70039d --- /dev/null +++ b/src/slices/authorization.ts @@ -0,0 +1,20 @@ +import { createSlice } from "@reduxjs/toolkit"; + +const authorizationSlice = createSlice({ + name: "authorization", + initialState: { + authorizing: false, + }, + reducers: { + startAuthorizing: (state) => { + state.authorizing = true; + }, + finishAuthorizing: (state) => { + state.authorizing = false; + }, + }, +}); + +export const { startAuthorizing, finishAuthorizing } = authorizationSlice.actions; + +export default authorizationSlice.reducer; diff --git a/src/store.ts b/src/store.ts new file mode 100644 index 0000000..1b9807b --- /dev/null +++ b/src/store.ts @@ -0,0 +1,21 @@ +import { combineReducers, configureStore } from "@reduxjs/toolkit"; + +import authorizationReducer from "./slices/authorization"; + +const rootReducer = combineReducers({ + authorization: authorizationReducer +}); + +export const setupStore = (preloadedState?: Partial<RootState>) => { + return configureStore({ + reducer: rootReducer, + preloadedState + }); +}; + +const formsStore = setupStore(); + +export default formsStore; + +export type RootState = ReturnType<typeof rootReducer> +export type AppStore = ReturnType<typeof setupStore> |