aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-07-09 20:20:38 +0100
committerGravatar Joe Banks <[email protected]>2024-07-10 01:56:38 +0100
commit5c8125a283fbb6c0ffd69b36e43ff655fc7ce8aa (patch)
tree5e472dc0ece0d14d2e73a8f2b7c4dd64dcdb190a /src
parentAdd @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.ts20
-rw-r--r--src/store.ts21
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>