initial docker setup
This commit is contained in:
225
frontend/src/reducers/cart/cartReducers.js
Normal file
225
frontend/src/reducers/cart/cartReducers.js
Normal file
@@ -0,0 +1,225 @@
|
||||
import {
|
||||
RECEIVE_SHOP_CART_COUNT,
|
||||
REQUEST_SHOP_CART_ITEMS,
|
||||
RECEIVE_SHOP_CART_ITEMS,
|
||||
SET_CURRENT_STEP,
|
||||
RESET_STEPS,
|
||||
GO_TO_NEXT_STEP,
|
||||
GO_TO_PREVIOUS_STEP,
|
||||
LOAD_CART_STEPS,
|
||||
REQUEST_CART_DOCUMENTS,
|
||||
RECEIVE_CART_DOCUMENTS,
|
||||
REQUEST_CUSTOMER_DETAILS,
|
||||
RECEIVE_CUSTOMER_DETAILS,
|
||||
SELECT_COUNTRY_DELIVERY,
|
||||
SELECT_COUNTRY_BILLING,
|
||||
SET_ORDER_INFO,
|
||||
IS_CART_ITEMS_DISABLED,
|
||||
RECEIVE_ORDER_TOTAL_PRICE,
|
||||
UPDATE_CART_ITEMS,
|
||||
SET_NEXT_STEP,
|
||||
SET_PREV_STEP,
|
||||
SET_ORDER_PLACED,
|
||||
SET_ORDER_PLACED_REDIRECT
|
||||
} from '../../constants/cartConstants';
|
||||
import PriceHelper from '../../helpers/coMarket/PriceHelper';
|
||||
|
||||
const priceHelper = new PriceHelper();
|
||||
const moduleReducers = {};
|
||||
|
||||
const calculateTotalPrice = (cartItems) => {
|
||||
let fixedPrice = priceHelper.sumPrices(cartItems.map(item => { return item.quantity * item.totalPrices.fixedPrice}));
|
||||
let recurrentPrice = priceHelper.sumPrices(cartItems.map(item => { return item.quantity * item.totalPrices.recurrentPrice})) || 0;
|
||||
let servicesPrice = priceHelper.sumPrices(cartItems.map(item => { return item.quantity * item.totalPrices.servicesPrice})) || 0;
|
||||
|
||||
return {
|
||||
fixedPrice,
|
||||
recurrentPrice: priceHelper.sumPrices([recurrentPrice, servicesPrice]),
|
||||
periodUnit: cartItems[0].periodUnit,
|
||||
currency: cartItems[0].country.currency
|
||||
}
|
||||
}
|
||||
|
||||
moduleReducers[RECEIVE_SHOP_CART_COUNT] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
cartCount: action.cartCount
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[UPDATE_CART_ITEMS] = (state, action) => {
|
||||
const newState = Object.assign({}, state);
|
||||
newState.cartItems.forEach((item) => {
|
||||
if(item.idCart === action.newItem.idCart){
|
||||
item = action.newItem;
|
||||
}
|
||||
});
|
||||
|
||||
return Object.assign({}, state, {
|
||||
cartItems: newState.cartItems,
|
||||
orderTotalPrice: calculateTotalPrice(newState.cartItems)
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[REQUEST_SHOP_CART_ITEMS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_SHOP_CART_ITEMS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
cartItems: action.cartItems,
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[LOAD_CART_STEPS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
cartSteps: action.cartSteps
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[REQUEST_CUSTOMER_DETAILS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
moduleReducers[RECEIVE_CUSTOMER_DETAILS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
customerDetails: action.customerDetails,
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SET_CURRENT_STEP] = (state, action) => {
|
||||
const cartSteps = Object.assign({}, state.cartSteps);
|
||||
|
||||
if(state.currentStep && cartSteps[state.currentStep]){
|
||||
cartSteps[state.currentStep].status = 'completed';
|
||||
}
|
||||
cartSteps[action.currentStep].status = 'active';
|
||||
|
||||
return Object.assign({}, state, {
|
||||
currentStep: action.currentStep,
|
||||
cartSteps
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RESET_STEPS] = (state, action) => {
|
||||
const cartSteps = Object.assign({}, state.cartSteps);
|
||||
Object.keys(cartSteps).forEach(stepName => {
|
||||
cartSteps[stepName].status = cartSteps[stepName].previous ? 'inactive' : 'active';
|
||||
});
|
||||
|
||||
return Object.assign({}, state, {
|
||||
cartSteps
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[GO_TO_NEXT_STEP] = (state, action) => {
|
||||
const cartSteps = Object.assign({}, state.cartSteps);
|
||||
const nextStep = cartSteps[state.currentStep].next || '';
|
||||
|
||||
if(nextStep && nextStep !== ''){
|
||||
cartSteps[nextStep].status = 'active';
|
||||
cartSteps[state.currentStep].status = 'completed';
|
||||
}
|
||||
|
||||
return Object.assign({}, state, {
|
||||
currentStep: nextStep,
|
||||
cartSteps
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[GO_TO_PREVIOUS_STEP] = (state, action) => {
|
||||
const cartSteps = Object.assign({}, state.cartSteps);
|
||||
const previousStep = cartSteps[state.currentStep].previous || '';
|
||||
|
||||
if(previousStep && previousStep !== ''){
|
||||
cartSteps[previousStep].status = 'active';
|
||||
cartSteps[state.currentStep].status = 'completed';
|
||||
}
|
||||
|
||||
return Object.assign({}, state, {
|
||||
currentStep: previousStep,
|
||||
cartSteps
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[REQUEST_CART_DOCUMENTS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
moduleReducers[RECEIVE_CART_DOCUMENTS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
cartDocuments: action.cartDocuments,
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SELECT_COUNTRY_DELIVERY] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
selectedCountryDelivery: action.selectedCountryDelivery
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SELECT_COUNTRY_BILLING] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
selectedCountryBilling: action.selectedCountryBilling
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SET_ORDER_INFO] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
orderInfo: action.orderInfo
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[IS_CART_ITEMS_DISABLED] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isCartItemsDisabled: action.isCartItemsDisabled
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_ORDER_TOTAL_PRICE] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
orderTotalPrice: calculateTotalPrice(action.cartItems)
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SET_NEXT_STEP] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
nextStepAction: action.nextStepAction
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SET_PREV_STEP] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
prevStepAction: action.prevStepAction
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SET_ORDER_PLACED] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
orderPlaced: action.orderPlaced
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SET_ORDER_PLACED_REDIRECT] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
orderPlacedRedirect: action.orderPlacedRedirect
|
||||
});
|
||||
};
|
||||
|
||||
const cartReducer = (state = {}, action) => {
|
||||
return moduleReducers[action.type] ?
|
||||
moduleReducers[action.type](state, action) :
|
||||
state;
|
||||
};
|
||||
|
||||
export default cartReducer;
|
||||
@@ -0,0 +1,73 @@
|
||||
import {
|
||||
REQUEST_PACKAGE_DETAILS,
|
||||
RECIEVE_PACKAGE_DETAILS,
|
||||
SELECT_OPTION,
|
||||
SELECT_AGREEMENT,
|
||||
SELECT_ADDITIONAL,
|
||||
REMOVE_ADDITIONAL,
|
||||
CLEAR_SELECTIONS
|
||||
} from '../../constants/coMarketConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[REQUEST_PACKAGE_DETAILS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECIEVE_PACKAGE_DETAILS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
selectedPackage: action.selectedPackage,
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[CLEAR_SELECTIONS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
selectedOptions: action.selectedOptions,
|
||||
selectedAdditionals: action.selectedAdditionals,
|
||||
selectedAgreement: action.selectedAgreement
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SELECT_AGREEMENT] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
selectedAgreement: action.selectedAgreement
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SELECT_OPTION] = (state, action) => {
|
||||
const newOptions = Object.assign({}, state.selectedOptions, action.selectedOptions);
|
||||
return Object.assign({}, state, {
|
||||
selectedOptions: newOptions
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SELECT_ADDITIONAL] = (state, action) => {
|
||||
const newState = {selectedAdditionals : []};
|
||||
newState.selectedAdditionals = state.selectedAdditionals ? newState.selectedAdditionals.concat(state.selectedAdditionals) : [];
|
||||
if(!newState.selectedAdditionals.includes(action.selectedAdditonal)){
|
||||
newState.selectedAdditionals.push(action.selectedAdditonal);
|
||||
}
|
||||
|
||||
return Object.assign({}, state, newState);
|
||||
};
|
||||
|
||||
moduleReducers[REMOVE_ADDITIONAL] = (state, action) => {
|
||||
const newState = {selectedAdditionals : []};
|
||||
newState.selectedAdditionals = state.selectedAdditionals ? newState.selectedAdditionals.concat(state.selectedAdditionals) : [];
|
||||
const indexOfElement = newState.selectedAdditionals.indexOf(action.selectedAdditonal);
|
||||
if(indexOfElement > -1){
|
||||
newState.selectedAdditionals.splice(indexOfElement, 1);
|
||||
}
|
||||
|
||||
return Object.assign({}, state, newState);
|
||||
};
|
||||
|
||||
const coMarketPackageDetailsReducer = (state = {}, action) => {
|
||||
|
||||
return moduleReducers[action.type] ? moduleReducers[action.type](state, action) : state;
|
||||
};
|
||||
|
||||
export default coMarketPackageDetailsReducer;
|
||||
40
frontend/src/reducers/coMarket/coMarketPackagesReducers.js
Normal file
40
frontend/src/reducers/coMarket/coMarketPackagesReducers.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import {
|
||||
RECIEVE_SHOP_PACKAGES,
|
||||
RECIEVE_SHOP_COMMERCIAL_LEADS,
|
||||
SELECT_SHOP_COMMERCIAL_LEAD,
|
||||
REQUEST_SHOP_PACKAGES
|
||||
} from '../../constants/coMarketConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[REQUEST_SHOP_PACKAGES] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECIEVE_SHOP_PACKAGES] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
shopPackages: action.shopPackages,
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECIEVE_SHOP_COMMERCIAL_LEADS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
commercialLeads: action.commercialLeads
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SELECT_SHOP_COMMERCIAL_LEAD] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
selectedCommercialLead: action.selectedCommercialLead
|
||||
});
|
||||
};
|
||||
|
||||
const coMarketPackagesReducer = (state = {}, action) => {
|
||||
|
||||
return moduleReducers[action.type] ? moduleReducers[action.type](state, action) : state;
|
||||
};
|
||||
|
||||
export default coMarketPackagesReducer;
|
||||
18
frontend/src/reducers/coMarket/coMarketReducers.js
Normal file
18
frontend/src/reducers/coMarket/coMarketReducers.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import {
|
||||
SET_PACKAGE_FROM_URL
|
||||
} from '../../constants/coMarketConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[SET_PACKAGE_FROM_URL] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
idPackage: action.idPackage
|
||||
});
|
||||
};
|
||||
|
||||
const coMarketReducer = (state = {}, action) => {
|
||||
|
||||
return moduleReducers[action.type] ? moduleReducers[action.type](state, action) : state;
|
||||
};
|
||||
|
||||
export default coMarketReducer;
|
||||
16
frontend/src/reducers/dashboard/dashboardReducers.js
Normal file
16
frontend/src/reducers/dashboard/dashboardReducers.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import {RECIEVE_GADGETS} from '../../constants/dashboardConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[RECIEVE_GADGETS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
gadgets: action.gadgets
|
||||
});
|
||||
};
|
||||
|
||||
const dashboardReducer = (state = {}, action) => {
|
||||
|
||||
return moduleReducers[action.type] ? moduleReducers[action.type](state, action) : state;
|
||||
};
|
||||
|
||||
export default dashboardReducer;
|
||||
23
frontend/src/reducers/dashboard/nextActionsReducers.js
Normal file
23
frontend/src/reducers/dashboard/nextActionsReducers.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import {REQUEST_NEXT_ACTIONS, RECIEVE_NEXT_ACTIONS} from '../../constants/dashboardConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[REQUEST_NEXT_ACTIONS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECIEVE_NEXT_ACTIONS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
nextActions: action.nextActions,
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
const nextActionsReducer = (state = {}, action) => {
|
||||
|
||||
return moduleReducers[action.type] ? moduleReducers[action.type](state, action) : state;
|
||||
};
|
||||
|
||||
export default nextActionsReducer;
|
||||
26
frontend/src/reducers/dashboard/ordersCentralReducer.js
Normal file
26
frontend/src/reducers/dashboard/ordersCentralReducer.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import {
|
||||
REQUEST_ORDERS,
|
||||
RECEIVE_ORDERS
|
||||
} from '../../constants/dashboardConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[REQUEST_ORDERS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_ORDERS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
orders: action.orders,
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
const ordersCentralReducer = (state = {}, action) => {
|
||||
|
||||
return moduleReducers[action.type] ? moduleReducers[action.type](state, action) : state;
|
||||
};
|
||||
|
||||
export default ordersCentralReducer;
|
||||
23
frontend/src/reducers/dialog/dialogReducers.js
Normal file
23
frontend/src/reducers/dialog/dialogReducers.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import {CONTENT_MESSAGE, IS_OPENED} from '../../constants/dialogConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[CONTENT_MESSAGE] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
dialogContent: action.dialogContent
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[IS_OPENED] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isDialogOpen: action.isDialogOpen
|
||||
});
|
||||
};
|
||||
|
||||
const dialogReducer = (state = {}, action) => {
|
||||
return moduleReducers[action.type]
|
||||
? moduleReducers[action.type](state, action)
|
||||
: state;
|
||||
};
|
||||
|
||||
export default dialogReducer;
|
||||
46
frontend/src/reducers/index.js
Normal file
46
frontend/src/reducers/index.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
combineReducers
|
||||
} from 'redux';
|
||||
import auth from './login/authReducers';
|
||||
import dashboardReducer from './dashboard/dashboardReducers';
|
||||
import ordersCentralReducer from './dashboard/ordersCentralReducer';
|
||||
import nextActionsReducer from './dashboard/nextActionsReducers';
|
||||
import coMarketReducer from './coMarket/coMarketReducers';
|
||||
import coMarketPackagesReducer from './coMarket/coMarketPackagesReducers';
|
||||
import coMarketPackageDetailsReducer from './coMarket/coMarketPackageDetailsReducers';
|
||||
import cartReducer from './cart/cartReducers';
|
||||
import processReducer from './orders/processReducers';
|
||||
import notificationReducer from './notification/notificationReducers';
|
||||
import dialogReducer from './dialog/dialogReducers';
|
||||
import ordersReducer from './orders/ordersReducers';
|
||||
import profileSettingsReducer from './profileSettings/profileSettingsReducers';
|
||||
import pageReducer from './page/pageReducer';
|
||||
import orderProjectsReducer from './orderProjects/orderProjectsReducer';
|
||||
|
||||
const wiaasReducers = combineReducers({
|
||||
auth,
|
||||
dashboardReducer,
|
||||
ordersCentralReducer,
|
||||
processReducer,
|
||||
nextActionsReducer,
|
||||
coMarketReducer,
|
||||
coMarketPackagesReducer,
|
||||
coMarketPackageDetailsReducer,
|
||||
cartReducer,
|
||||
notificationReducer,
|
||||
dialogReducer,
|
||||
ordersReducer,
|
||||
profileSettingsReducer,
|
||||
pageReducer,
|
||||
orderProjectsReducer
|
||||
});
|
||||
|
||||
const rootReducer = (state, action) => {
|
||||
if (action.type === 'LOGOUT') {
|
||||
state = undefined;
|
||||
}
|
||||
|
||||
return wiaasReducers(state, action);
|
||||
}
|
||||
|
||||
export default rootReducer;
|
||||
60
frontend/src/reducers/login/authReducers.js
Normal file
60
frontend/src/reducers/login/authReducers.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import {
|
||||
LOGOUT,
|
||||
LOGIN_SUCCESS,
|
||||
LOGIN_FAIL,
|
||||
REQUEST_FORGOT_PASSWORD,
|
||||
FORGOT_PASSWORD,
|
||||
RECIEVE_MODULES,
|
||||
PASSWORD_CHANGED,
|
||||
SET_COMPANY_ADMIN_FLAG
|
||||
} from '../../constants/authConstants';
|
||||
|
||||
function auth(state = {}, action) {
|
||||
switch (action.type) {
|
||||
case LOGIN_SUCCESS:
|
||||
return Object.assign({}, state, {
|
||||
isLoggedIn: action.isLoggedIn,
|
||||
userInfo: action.userInfo
|
||||
});
|
||||
case LOGOUT:
|
||||
return Object.assign({}, state, {
|
||||
isLoggedIn: action.isLoggedIn,
|
||||
errorMessage: action.errorMessage,
|
||||
messageColor: 'success'
|
||||
});
|
||||
case LOGIN_FAIL:
|
||||
return Object.assign({}, state, {
|
||||
isLoggedIn: action.isLoggedIn,
|
||||
errorMessage: action.errorMessage,
|
||||
messageColor: 'danger'
|
||||
});
|
||||
case REQUEST_FORGOT_PASSWORD:
|
||||
return Object.assign({}, state, {
|
||||
errorMessage: action.errorMessage,
|
||||
messageColor: 'success'
|
||||
});
|
||||
case FORGOT_PASSWORD:
|
||||
return Object.assign({}, state, {
|
||||
errorMessage: action.errorMessage,
|
||||
messageColor: action.messageColor
|
||||
});
|
||||
case RECIEVE_MODULES:
|
||||
return Object.assign({}, state, {
|
||||
modules: action.modules
|
||||
});
|
||||
case PASSWORD_CHANGED:
|
||||
return Object.assign({}, state, {
|
||||
errorMessage: action.errorMessage,
|
||||
messageColor: action.messageColor,
|
||||
isPasswordChanged: action.isPasswordChanged
|
||||
});
|
||||
case SET_COMPANY_ADMIN_FLAG:
|
||||
return Object.assign({}, state, {
|
||||
isCompanyAdmin: action.isCompanyAdmin
|
||||
});
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export default auth;
|
||||
17
frontend/src/reducers/notification/notificationReducers.js
Normal file
17
frontend/src/reducers/notification/notificationReducers.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import {UPDATE_MESSAGES} from '../../constants/notificationConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[UPDATE_MESSAGES] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
updateMessages: action.updateMessages
|
||||
});
|
||||
};
|
||||
|
||||
const notificationReducer = (state = {}, action) => {
|
||||
return moduleReducers[action.type]
|
||||
? moduleReducers[action.type](state, action)
|
||||
: state;
|
||||
};
|
||||
|
||||
export default notificationReducer;
|
||||
26
frontend/src/reducers/orderProjects/orderProjectsReducer.js
Normal file
26
frontend/src/reducers/orderProjects/orderProjectsReducer.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import {
|
||||
REQUEST_ORDER_PROJECTS,
|
||||
RECEIVE_ORDER_PROJECTS
|
||||
} from '../../constants/orderProjectsConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[REQUEST_ORDER_PROJECTS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_ORDER_PROJECTS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
orderProjects: action.orderProjects,
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
const orderPackagesReducer = (state = {}, action) => {
|
||||
|
||||
return moduleReducers[action.type] ? moduleReducers[action.type](state, action) : state;
|
||||
};
|
||||
|
||||
export default orderPackagesReducer;
|
||||
50
frontend/src/reducers/orders/ordersReducers.js
Normal file
50
frontend/src/reducers/orders/ordersReducers.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import {
|
||||
REQUEST_ACTIVE_ORDERS,
|
||||
RECEIVE_ACTIVE_ORDERS,
|
||||
REQUEST_HISTORY_ORDERS,
|
||||
RECEIVE_HISTORY_ORDERS,
|
||||
SET_VIEW_ALL_ORDERS
|
||||
} from '../../constants/ordersConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[REQUEST_ACTIVE_ORDERS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_ACTIVE_ORDERS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
activeOrders: action.activeOrders,
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[REQUEST_HISTORY_ORDERS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_HISTORY_ORDERS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
historyOrders: action.historyOrders
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SET_VIEW_ALL_ORDERS] = (state, action) => {
|
||||
const oldState = Object.assign({}, state.isViewAllOrdersChecked);
|
||||
const newState = Object.assign(oldState, action.isViewAllOrdersChecked);
|
||||
|
||||
return Object.assign({}, state, {
|
||||
isViewAllOrdersChecked: newState
|
||||
});
|
||||
};
|
||||
|
||||
const ordersReducer = (state = {}, action) => {
|
||||
|
||||
return moduleReducers[action.type] ? moduleReducers[action.type](state, action) : state;
|
||||
};
|
||||
|
||||
export default ordersReducer;
|
||||
121
frontend/src/reducers/orders/processReducers.js
Normal file
121
frontend/src/reducers/orders/processReducers.js
Normal file
@@ -0,0 +1,121 @@
|
||||
import {
|
||||
REQUEST_ORDER_INFO,
|
||||
RECEIVE_ORDER_INFO,
|
||||
RECEIVE_CUSTOMER_DOCUMENTS,
|
||||
RECEIVE_VALIDATION_COMMENTS,
|
||||
RECEIVE_CUSTOMER_ACCEPTANCE,
|
||||
RECEIVE_IS_COMPONENT_DISABLED,
|
||||
RECEIVE_IS_NEXT_STEP_WANTED,
|
||||
SET_EARLIEST_INSTALLATION_DATE,
|
||||
SET_CONFIRMATION_DATES,
|
||||
RECEIVE_INSTALLATION_COMPANIES,
|
||||
RECEIVE_ALL_SHIPPING_DATES_CONFIRMED,
|
||||
SET_SUPPORT_MESSAGE,
|
||||
SET_SCHEDULING_DISABLED_FLAG
|
||||
} from '../../constants/ordersConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[REQUEST_ORDER_INFO] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_ORDER_INFO] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
orderInfo: action.orderInfo,
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_CUSTOMER_DOCUMENTS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
customerDocuments: action.customerDocuments
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_VALIDATION_COMMENTS] = (state, action) => {
|
||||
const oldComments = Object.assign({}, state.validationComments);
|
||||
const newComments = Object.assign(oldComments, action.validationComments);
|
||||
|
||||
return Object.assign({}, state, {
|
||||
validationComments: newComments
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_CUSTOMER_ACCEPTANCE] = (state, action) => {
|
||||
const oldAcceptance = Object.assign({}, state.customerAcceptance);
|
||||
const newAcceptance = Object.assign(oldAcceptance, action.customerAcceptance);
|
||||
|
||||
return Object.assign({}, state, {
|
||||
customerAcceptance: newAcceptance
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_IS_COMPONENT_DISABLED] = (state, action) => {
|
||||
const newState = {isComponentDisabled : {}};
|
||||
newState.isComponentDisabled.installationScheduling = state.isComponentDisabled && state.isComponentDisabled.installationScheduling
|
||||
? state.isComponentDisabled.installationScheduling
|
||||
: {};
|
||||
Object.assign(newState.isComponentDisabled.installationScheduling, action.isComponentDisabled.installationScheduling);
|
||||
|
||||
return Object.assign({}, state, newState);
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_IS_NEXT_STEP_WANTED] = (state, action) => {
|
||||
const newState = {isNextStepWanted : {}};
|
||||
newState.isNextStepWanted.installationScheduling = state.isNextStepWanted && state.isNextStepWanted.installationScheduling
|
||||
? state.isNextStepWanted.installationScheduling
|
||||
: {};
|
||||
Object.assign(newState.isNextStepWanted.installationScheduling, action.isNextStepWanted.installationScheduling);
|
||||
|
||||
return Object.assign({}, state, newState);
|
||||
};
|
||||
|
||||
moduleReducers[SET_EARLIEST_INSTALLATION_DATE] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
earliestInstallDate: action.earliestInstallDate
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SET_CONFIRMATION_DATES] = (state, action) => {
|
||||
const oldDates = Object.assign({}, state.confirmationDates);
|
||||
const newDates = Object.assign(oldDates, action.confirmationDates);
|
||||
|
||||
return Object.assign({}, state, {
|
||||
confirmationDates: newDates
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECEIVE_INSTALLATION_COMPANIES] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
installCompanies: action.installCompanies
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SET_SUPPORT_MESSAGE] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
supportText: action.supportText
|
||||
});
|
||||
}
|
||||
|
||||
moduleReducers[SET_SCHEDULING_DISABLED_FLAG] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isSchedulingDisabled: action.isSchedulingDisabled
|
||||
});
|
||||
}
|
||||
|
||||
moduleReducers[RECEIVE_ALL_SHIPPING_DATES_CONFIRMED] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
areAllShippingDatesConfirmed: action.areAllShippingDatesConfirmed
|
||||
});
|
||||
}
|
||||
|
||||
const processReducer = (state = {}, action) => {
|
||||
return moduleReducers[action.type]
|
||||
? moduleReducers[action.type](state, action)
|
||||
: state;
|
||||
};
|
||||
|
||||
export default processReducer;
|
||||
47
frontend/src/reducers/page/pageReducer.js
Normal file
47
frontend/src/reducers/page/pageReducer.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
SET_PARAMS_FROM_URL,
|
||||
RESET_PARAMS,
|
||||
SET_ACTIVE_MODULE,
|
||||
SET_ACTIVE_SUB_MODULE,
|
||||
RESET_ACTIVE_SUB_MODULE
|
||||
} from '../../constants/pageConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[SET_PARAMS_FROM_URL] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
urlParams: action.urlParams
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RESET_PARAMS] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
urlParams: {}
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SET_ACTIVE_MODULE] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
activeModule: action.activeModule
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[SET_ACTIVE_SUB_MODULE] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
activeSubmodule: action.activeSubmodule
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RESET_ACTIVE_SUB_MODULE] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
activeSubmodule: ''
|
||||
});
|
||||
};
|
||||
|
||||
const pageReducer = (state = {}, action) => {
|
||||
return moduleReducers[action.type]
|
||||
? moduleReducers[action.type](state, action)
|
||||
: state;
|
||||
};
|
||||
|
||||
export default pageReducer;
|
||||
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
REQUEST_PROFILE_INFO,
|
||||
RECIEVE_PROFILE_INFO,
|
||||
REQUEST_COUNTRIES,
|
||||
RECIEVE_COUNTRIES
|
||||
} from '../../constants/profileSettingsConstants';
|
||||
|
||||
const moduleReducers = {};
|
||||
|
||||
moduleReducers[REQUEST_PROFILE_INFO] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECIEVE_PROFILE_INFO] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
profileInfo: action.profileInfo,
|
||||
isLoading: action.isLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[REQUEST_COUNTRIES] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
areCountriesLoading: action.areCountriesLoading
|
||||
});
|
||||
};
|
||||
|
||||
moduleReducers[RECIEVE_COUNTRIES] = (state, action) => {
|
||||
return Object.assign({}, state, {
|
||||
countries: action.countries,
|
||||
areCountriesLoading: action.areCountriesLoading
|
||||
});
|
||||
};
|
||||
|
||||
const profileSettingsReducer = (state = {}, action) => {
|
||||
|
||||
return moduleReducers[action.type] ? moduleReducers[action.type](state, action) : state;
|
||||
};
|
||||
|
||||
export default profileSettingsReducer;
|
||||
Reference in New Issue
Block a user