Blame view

redux/reducers/enquiryReducer.js 1.22 KB
jaymehta committed
1 2 3 4 5 6 7 8
import {
  ENQUIRY_SUBMIT_FAIL,
  ENQUIRY_SUBMIT_REQUEST,
  ENQUIRY_SUBMIT_SUCCESS,
  GET_ENQUIRIES_BY_VENDOR_FAIL,
  GET_ENQUIRIES_BY_VENDOR_REQUEST,
  GET_ENQUIRIES_BY_VENDOR_SUCCESS
} from "../constants/enquiryConstants";
jay committed
9 10 11 12 13 14 15 16 17 18 19 20

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,
jaymehta committed
21
        enquiry: action.payload
jay committed
22 23 24 25 26 27 28 29 30 31 32 33
      };
    case ENQUIRY_SUBMIT_FAIL:
      return {
        loading: false,
        success: false,
        error: action.payload.error.message
      };

    default:
      return state;
  }
};
jaymehta committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

export const getEnquiriesReducer = (state = { enquiriesByVendor: null }, action) => {
  switch (action.type) {
    case GET_ENQUIRIES_BY_VENDOR_REQUEST:
      return {
        loading: true,
      };
    case GET_ENQUIRIES_BY_VENDOR_SUCCESS:
      return {
        loading: false,
        enquiriesByVendor: action.payload
      };
    case GET_ENQUIRIES_BY_VENDOR_FAIL:
      return {
        loading: false,
        error: action.payload.error.message
      };

    default:
      return state;
  }
};