Initial commit

This commit is contained in:
Luka Radenovic 2021-09-27 12:17:33 +02:00
commit fa30c04815
117 changed files with 33513 additions and 0 deletions

2
src/redux/index.ts Normal file
View file

@ -0,0 +1,2 @@
export { configureStore } from './store';
export * from './types';

35
src/redux/store.ts Normal file
View file

@ -0,0 +1,35 @@
import { createStore, compose, applyMiddleware, combineReducers } from 'redux';
import thunkMiddleware from 'redux-thunk';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import { reducer as authReducer } from 'src/services/auth';
import { reducer as usersReducer } from 'src/services/users';
import { State } from './types';
const persistConfig = {
key: 'root',
storage,
whitelist: ['auth'],
};
const appReducer = combineReducers<State>({
auth: authReducer,
users: usersReducer,
});
const persistedReducer = persistReducer(persistConfig, appReducer);
const middlewares = [thunkMiddleware];
// @ts-ignore
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
export const configureStore = () => {
const store = createStore(persistedReducer, composeEnhancers(applyMiddleware(...middlewares)));
const persistor = persistStore(store);
return { store, persistor };
};

11
src/redux/types.ts Normal file
View file

@ -0,0 +1,11 @@
import { Store } from 'redux';
import { AuthState } from 'src/services/auth/redux';
import { UsersState } from 'src/services/users/redux';
export interface AppStore extends Store, State {}
export interface State {
auth: AuthState;
users: UsersState;
}