WIP Loading Header & Remaining changes from Sprint 1
This commit is contained in:
10
client/src/redux/application/application.actions.js
Normal file
10
client/src/redux/application/application.actions.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import ApplicationActionTypes from "./application.types";
|
||||
|
||||
export const startLoading = () => ({
|
||||
type: ApplicationActionTypes.START_LOADING
|
||||
});
|
||||
|
||||
export const endLoading = options => ({
|
||||
type: ApplicationActionTypes.END_LOADING,
|
||||
payload: options
|
||||
});
|
||||
24
client/src/redux/application/application.reducer.js
Normal file
24
client/src/redux/application/application.reducer.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import ApplicationActionTypes from "./application.types";
|
||||
|
||||
const INITIAL_STATE = {
|
||||
loading: false
|
||||
};
|
||||
|
||||
const applicationReducer = (state = INITIAL_STATE, action) => {
|
||||
switch (action.type) {
|
||||
case ApplicationActionTypes.START_LOADING:
|
||||
return {
|
||||
...state,
|
||||
loading: true
|
||||
};
|
||||
case ApplicationActionTypes.END_LOADING:
|
||||
return {
|
||||
...state,
|
||||
loading: false
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default applicationReducer;
|
||||
8
client/src/redux/application/application.selectors.js
Normal file
8
client/src/redux/application/application.selectors.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createSelector } from "reselect";
|
||||
|
||||
const selectApplication = state => state.application;
|
||||
|
||||
export const selectLoading = createSelector(
|
||||
[selectApplication],
|
||||
application => application.loading
|
||||
);
|
||||
5
client/src/redux/application/application.types.js
Normal file
5
client/src/redux/application/application.types.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const ApplicationActionTypes = {
|
||||
START_LOADING: "START_LOADING",
|
||||
END_LOADING: "END_LOADING"
|
||||
};
|
||||
export default ApplicationActionTypes;
|
||||
@@ -5,7 +5,8 @@ import storage from "redux-persist/lib/storage";
|
||||
import userReducer from "./user/user.reducer";
|
||||
import messagingReducer from "./messaging/messaging.reducer";
|
||||
import emailReducer from "./email/email.reducer";
|
||||
import modalsReducer from './modals/modals.reducer'
|
||||
import modalsReducer from "./modals/modals.reducer";
|
||||
import applicationReducer from "./application/application.reducer";
|
||||
const persistConfig = {
|
||||
key: "root",
|
||||
storage,
|
||||
@@ -17,7 +18,8 @@ const rootReducer = combineReducers({
|
||||
user: userReducer,
|
||||
messaging: messagingReducer,
|
||||
email: emailReducer,
|
||||
modals: modalsReducer
|
||||
modals: modalsReducer,
|
||||
application: applicationReducer
|
||||
});
|
||||
|
||||
export default persistReducer(persistConfig, rootReducer);
|
||||
|
||||
Reference in New Issue
Block a user