import { VALIDATE_IDENTIFICATION_PENDING, VALIDATE_IDENTIFICATION_SUCCESS, VALIDATE_IDENTIFICATION_ERROR, VALIDATE_IDENTIFICATION_RESET } from "../types/IdentificationType";

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

export default (state = initialState, action) => {
     switch (action.type) {
          case VALIDATE_IDENTIFICATION_PENDING: return {
               ...state,
               loading: true
          }
          case VALIDATE_IDENTIFICATION_SUCCESS: return {
               ...state,
               loading: false,
               result: action.result.data,
               error: null
          }
          case VALIDATE_IDENTIFICATION_ERROR: return {
               ...state,
               loading: false,
               result: null,
               error: action.result
          }
          case VALIDATE_IDENTIFICATION_RESET: return initialState;

          default: {
               return state;
          }
     }
};
