import { SAVE_ONESIGNAL_IDS_PENDING, SAVE_ONESIGNAL_IDS_SUCCESS, SAVE_ONESIGNAL_IDS_ERROR, SAVE_ONESIGNAL_IDS_RESET } from "../types/NotificationType";

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

export default (state = initialState, action) => {
     switch (action.type) {
          case SAVE_ONESIGNAL_IDS_PENDING: return {
               ...state,
               loading: true
          }
          case SAVE_ONESIGNAL_IDS_SUCCESS: return {
               ...state,
               loading: false,
               result: action.result.data,
               error: null
          }
          case SAVE_ONESIGNAL_IDS_ERROR: return {
               ...state,
               loading: false,
               result: null,
               error: action.result
          }
          case SAVE_ONESIGNAL_IDS_RESET: return initialState;

          default: {
               return state;
          }
     }
};
