enquiryReducer.js 641 Bytes
import { ENQUIRY_SUBMIT_FAIL, ENQUIRY_SUBMIT_REQUEST, ENQUIRY_SUBMIT_SUCCESS } from "../constants/enquiryConstants";

export const enquiryReducer = (state = { enquiry: null }, action) => {
  switch (action.type) {
    case ENQUIRY_SUBMIT_REQUEST:
      return {
        loading: true,
        success: false
      };
    case ENQUIRY_SUBMIT_SUCCESS:
      return {
        loading: false,
        success: true,
        referral: action.payload
      };
    case ENQUIRY_SUBMIT_FAIL:
      return {
        loading: false,
        success: false,
        error: action.payload.error.message
      };

    default:
      return state;
  }
};