1 |
37f6ff02
|
Vaclav Honzik
|
import { applyMiddleware, combineReducers, createStore } from 'redux'
|
2 |
a69da1e3
|
Vaclav Honzik
|
import { persistStore } from 'redux-persist'
|
3 |
37f6ff02
|
Vaclav Honzik
|
import thunk from 'redux-thunk'
|
4 |
8370b6c1
|
Vaclav Honzik
|
import userReducer from '../Auth/userSlice'
|
5 |
c7d2ced1
|
Václav Honzík
|
import themeReducer from '../Theme/themeReducer'
|
6 |
394f2d16
|
Vaclav Honzik
|
import catalogReducer from '../Catalog/catalogSlice'
|
7 |
1c710f4f
|
Vaclav Honzik
|
import { composeWithDevTools } from 'redux-devtools-extension'
|
8 |
c7d2ced1
|
Václav Honzík
|
|
9 |
1c710f4f
|
Vaclav Honzik
|
const composeEnhancers = composeWithDevTools({})
|
10 |
8042e8b3
|
Vaclav Honzik
|
|
11 |
a69da1e3
|
Vaclav Honzik
|
// Store holds shared state in the application
|
12 |
c7d2ced1
|
Václav Honzík
|
const store = createStore(
|
13 |
1c710f4f
|
Vaclav Honzik
|
combineReducers({
|
14 |
|
|
user: userReducer,
|
15 |
|
|
theme: themeReducer,
|
16 |
|
|
catalog: catalogReducer,
|
17 |
|
|
}),
|
18 |
|
|
process.env.REACT_APP_DEV_ENV === 'true'
|
19 |
|
|
? composeEnhancers(
|
20 |
|
|
applyMiddleware(thunk) // Thunk middleware so we can async fetch data from the api
|
21 |
|
|
)
|
22 |
|
|
: applyMiddleware(thunk)
|
23 |
c7d2ced1
|
Václav Honzík
|
)
|
24 |
|
|
|
25 |
|
|
export default store
|
26 |
a69da1e3
|
Vaclav Honzik
|
export const persistor = persistStore(store)
|
27 |
c7d2ced1
|
Václav Honzík
|
export type AppStore = typeof store
|
28 |
|
|
export type RootState = ReturnType<typeof store.getState>
|
29 |
|
|
export type AppDispatch = typeof store.dispatch
|