1
|
import { applyMiddleware, combineReducers, createStore } from 'redux'
|
2
|
import { persistStore } from 'redux-persist'
|
3
|
import thunk from 'redux-thunk'
|
4
|
import userReducer from '../Auth/userSlice'
|
5
|
import themeReducer from '../Theme/themeSlice'
|
6
|
import catalogReducer from '../Catalog/catalogSlice'
|
7
|
import { composeWithDevTools } from 'redux-devtools-extension'
|
8
|
import notificationReducer from '../Notification/notificationSlice'
|
9
|
import trackingToolReducer from '../TrackingTool/trackingToolSlice'
|
10
|
import usersDetailReducer from '../Administration/userDetailSlice'
|
11
|
import { enableMapSet } from 'immer'
|
12
|
import navigationReducer from '../Navigation/navigationSlice'
|
13
|
|
14
|
enableMapSet()
|
15
|
|
16
|
const composeEnhancers = composeWithDevTools({})
|
17
|
|
18
|
// Store holds shared state in the application
|
19
|
const store = createStore(
|
20
|
combineReducers({
|
21
|
user: userReducer,
|
22
|
theme: themeReducer,
|
23
|
catalog: catalogReducer,
|
24
|
notification: notificationReducer,
|
25
|
trackingTool: trackingToolReducer,
|
26
|
usersDetail: usersDetailReducer,
|
27
|
navigation: navigationReducer,
|
28
|
}),
|
29
|
process.env.REACT_APP_DEV_ENV === 'true'
|
30
|
? composeEnhancers(
|
31
|
// ComposeEnhancers will inject redux-devtools-extension
|
32
|
applyMiddleware(thunk) // Thunk middleware so we can async fetch data from the api
|
33
|
)
|
34
|
: applyMiddleware(thunk)
|
35
|
)
|
36
|
|
37
|
export default store
|
38
|
export const persistor = persistStore(store)
|
39
|
export type AppStore = typeof store
|
40
|
export type RootState = ReturnType<typeof store.getState>
|
41
|
export type AppDispatch = typeof store.dispatch
|