import { combineReducers } from 'redux'
import { UserActionTypes } from '../redux/user/action.types'
import userReducer from './user/user.reducer'
import educatorRegistrationReducer from './educator/educator.reducer'
import patientRegistrationReducer from './patient/patient.reducer'
import visitorReducer from "./visitor/visitor.reducer";
import medicalLogReducer from './dashboard/medical-logs/medical-logs.reducer'
import subscriptionCodeReducer from './dashboard/subscription-codes/subscription-codes.reducer'
import remoteNotificationReducer from './dashboard/notification-header/remote-notification.reducer'
import chatNotificationReducer from './dashboard/chat-box/chat-box.reducer'
import remoteNotificationDetailReducer from './dashboard/notification-detail/notification-detail.reducer'
import dailyLogReducer from './dashboard/daily-logs/daily-logs.reducer'
import patientListReducer from './dashboard/patient-list/patient-list.reducer'
import educatorListReducer from './dashboard/educator-list/educator-list.reducer'
import subscriptionCodeListReducer from './dashboard/susbcription-code-list/susbcription-code-list.reducer'
import labReportReducer from './dashboard/lab-report/lab-report.reducer'
import dietPlanReducer from './dashboard/diet-plan/diet-plan.reducer'
import dashboardContentReducer from './dashboard/dashboard-detail/dashboard-detail.reducer'
const appReducer = combineReducers({
        /* your app’s top-level reducers */

    user: userReducer,
    educatorRegistration: educatorRegistrationReducer,
    patientRegistration: patientRegistrationReducer,
    subscriptionCoder: subscriptionCodeReducer,
    visitors: visitorReducer,
    caseHistory: medicalLogReducer,
    remoteNotification:remoteNotificationReducer,
    remoteNotificationDetail:remoteNotificationDetailReducer,
    dailyLogs: dailyLogReducer,
    chatter:chatNotificationReducer,
    patientList: patientListReducer,
    educatorList: educatorListReducer,
    subscriptionList: subscriptionCodeListReducer,
    labReport: labReportReducer,
    dietPlan:dietPlanReducer,
    dashboardContent: dashboardContentReducer
})

  
const rootReducer = (state, action) => {
    // when a logout action is dispatched it will reset redux state
    if (action.type === UserActionTypes.USER_LOGGED_OUT) {
      state = undefined;
    }
  
    return appReducer(state, action);
  }

  export default rootReducer