// import * as R from 'ramda';
// import {AuthAction} from '@/auth/auth.interface';
// import {DesktopAction} from '@/layout/desktop.interface';

import {
  SystemAction,
  SystemState,
} from './system.interface';


  import * as Module from '@/layout/module/module.reducer';
  
  export const initialState: SystemState = {
    isLoading: false,
    ...Module.initialState,
  };
  
export const reducerSystem = (state: SystemState, action: SystemAction) => {
  switch (action.type) { 
    case 'start_loading': {
      return {
        ...state,
        isLoading: true
      }
    }

    case 'end_loading': {
      return {
        ...state,
        isLoading: false
      }
    }

    default:
      return state;
  }
};

// const composeReducers = (...reduces: any[]) => {
//   return reduces.forEach(fn => fn());
// }


export const reducer = (state: SystemState, action: any) => {
  let newState = state;
  newState = reducerSystem(newState, action);
  newState = Module.reducer(newState, action) as SystemState;
  return newState;
}