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;
