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

const initialState = {
  mainIndex: null,
  sendSms: {},
};

export const appDataReducer = (state = initialState, action) => {
  switch (action.type) {
    case types.ADD_MAIN_INDEX:
      return {
        ...state,
        mainIndex: action.payload,
      };
    case types.SEND_SMS:
      return {
        ...state,
        sendSms: { retCode: action.retCode },
      };
    case types.CLEAR_SMS:
      return {
        ...state,
        sendSms: { retCode: undefined },
      };
    default:
      return state;
  }
};
