referralReducer.js
650 Bytes
import { REFERRAL_SUBMIT_FAIL, REFERRAL_SUBMIT_REQUEST, REFERRAL_SUBMIT_SUCCESS } from "../constants/referralConstants";
export const referralReducer = (state = { referral: null }, action) => {
switch (action.type) {
case REFERRAL_SUBMIT_REQUEST:
return {
loading: true,
success: false
};
case REFERRAL_SUBMIT_SUCCESS:
return {
loading: false,
success: true,
referral: action.payload
};
case REFERRAL_SUBMIT_FAIL:
return {
loading: false,
success: false,
error: action.payload.error.message
};
default:
return state;
}
};