From 5c8125a283fbb6c0ffd69b36e43ff655fc7ce8aa Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Tue, 9 Jul 2024 20:20:38 +0100 Subject: Add new redux stores and slices for authorization state --- src/slices/authorization.ts | 20 ++++++++++++++++++++ src/store.ts | 21 +++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/slices/authorization.ts create mode 100644 src/store.ts 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) => { + return configureStore({ + reducer: rootReducer, + preloadedState + }); +}; + +const formsStore = setupStore(); + +export default formsStore; + +export type RootState = ReturnType +export type AppStore = ReturnType -- cgit v1.2.3