Projekt

Obecné

Profil

Stáhnout (1.7 KB) Statistiky
| Větev: | Tag: | Revize:
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
import catalogItemReducer from "../Catalog/catalogItemSlice"
14

    
15
enableMapSet()
16

    
17
const composeEnhancers = composeWithDevTools({})
18

    
19
// Store holds shared state in the application to remove the need for passing state to every component
20
const store = createStore(
21
    combineReducers({
22
        user: userReducer,
23
        theme: themeReducer,
24
        catalog: catalogReducer,
25
        notification: notificationReducer,
26
        trackingTool: trackingToolReducer,
27
        usersDetail: usersDetailReducer,
28
        catalogItem: catalogItemReducer,
29
        navigation: navigationReducer,
30
    }),
31
    process.env.REACT_APP_DEV_ENV === 'true'
32
        ? composeEnhancers(
33
              // ComposeEnhancers will inject redux-devtools-extension
34
              applyMiddleware(thunk) // Thunk middleware so we can async fetch data from the api
35
          )
36
        : applyMiddleware(thunk)
37
)
38

    
39
export default store
40
export const persistor = persistStore(store)
41
export type AppStore = typeof store
42
export type RootState = ReturnType<typeof store.getState>
43
export type AppDispatch = typeof store.dispatch
    (1-1/1)