import { PAY_COUNTRY_NETWORK_ERROR, PAY_COUNTRY_NETWORK_PENDING, PAY_COUNTRY_NETWORK_RESET, PAY_COUNTRY_NETWORK_SUCCESS } from "../types/CountryNetworkType";

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

export default (state = initialState, action) => {
     switch (action.type) {
          case PAY_COUNTRY_NETWORK_PENDING: return {
               ...state,
               loading: true
          }
          case PAY_COUNTRY_NETWORK_SUCCESS: return {
               ...state,
               loading: false,
               result: action.result.data,
               error: null
          }
          case PAY_COUNTRY_NETWORK_ERROR: return {
               ...state,
               loading: false,
               result: null,
               error: action.result
          }
          case PAY_COUNTRY_NETWORK_RESET: return initialState;

          default: {
               return state;
          }
     }
};
