blob: bc7be19c6ab0bafe0b78279f3af8a1843b756b6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import { combineReducers, configureStore } from '@reduxjs/toolkit';
import guestReducer from './slices/auth/guestSlice';
import adminReducer from './slices/auth/adminSlice';
import uiReducer from './slices/uiSlice';
import { guestSlice } from './slices/api/guestSlice';
import { adminSlice } from './slices/api/adminSlice';
const rootReducer = combineReducers({
[guestSlice.reducerPath]: guestSlice.reducer,
[adminSlice.reducerPath]: adminSlice.reducer,
guest: guestReducer,
admin: adminReducer,
ui: uiReducer,
});
const setupStore = (preloadedState?: Partial<RootState>) => {
return configureStore({
reducer: rootReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat(
guestSlice.middleware,
adminSlice.middleware
),
preloadedState,
});
};
export default setupStore;
export type RootState = ReturnType<typeof rootReducer>;
export type AppStore = ReturnType<typeof configureStore>;
export type AppDispatch = AppStore['dispatch'];
|