import { ACTIVE_COUNTRY_LIST_PENDING, ACTIVE_COUNTRY_LIST_SUCCESS, ACTIVE_COUNTRY_LIST_ERROR, ACTIVE_COUNTRY_LIST_RESET } from "../types/CountryNetworkType";

const initialState = {
     loading: false,
     result: null,
     error: null
};

export default (state = initialState, action) => {
     switch (action.type) {
          case ACTIVE_COUNTRY_LIST_PENDING: return {
               ...state,
               loading: true
          }
          case ACTIVE_COUNTRY_LIST_SUCCESS: return {
               ...state,
               loading: false,
               result: action.result.data,
               error: null
          }
          case ACTIVE_COUNTRY_LIST_ERROR: return {
               ...state,
               loading: false,
               result: null,
               error: action.result
          }
          case ACTIVE_COUNTRY_LIST_RESET: return initialState;

          default: {
               return state;
          }
     }
};
