import { types } from "../actions/actionTypes";

const initialState = {
  eventData: {},
  eventClickSuccess: null,
  curationCouponSuccess: undefined,
  eventIssuedStatusSuccess: null,
};

export const eventReducer = (state = initialState, action) => {
  switch (action.type) {
    case types.GET_WELCOME_EVENT_INFO:
      return {
        ...state,
        eventData: action.payload,
        retCode: action.retCode,
      };
    case types.SET_EVENT_POP_CLICK_INFO:
      return {
        ...state,
        eventClickSuccess: action.retCode,
      };
    case types.SET_EVENT_ISSUE_REQ:
      return {
        ...state,
        curationCouponSuccess: action.retCode,
      };
    case types.GET_EVENT_ISSUED_STATUS:
      return {
        ...state,
        eventIssuedStatusSuccess: action.retCode,
      };
    case types.CLEAR_EVENT_INFO:
      return {
        ...state,
        eventData: {},
        retCode: null,
      };
    case types.CLEAR_CURATION_COUPON:
      return {
        ...state,
        curationCouponSuccess: undefined,
      };
    case types.CLEAR_EVENT_ISSUED_STATUS_SUCCEESS:
      return {
        ...state,
        eventIssuedStatusSuccess: null,
      };
    default:
      return state;
  }
};
