import { types } from "../actions/actionTypes";
import {
  GET_TERMS_AGREE_YN_FAIL,
} from "../actions/commonActions";

const initialState = {
  regDeviceData: {},
  regDeviceInfoData: {},
};

export const deviceReducer = (state = initialState, action) => {
  switch (action.type) {
    case types.REGISTER_DEVICE:
      return {
        ...state,
        regDeviceData: { retCode: action.retCode },
      };
    case types.REGISTER_DEVICE_INFO:
      return {
        ...state,
        regDeviceInfoData: { retCode: action.retCode },
      };
    case types.GET_DEVICE_INFO:
      return {
        ...state,
        deviceInfo: action.payload.data.dvcInfo,
      };
    case types.CLEAR_REGISTER_DEVICE_INFO:
      return {
        ...state,
        regDeviceData: null,
      };
    case types.REGISTER_DEVICE_RESET:
      return {
        ...state,
        regDeviceData: null,
      };
    default:
      return state;
  }
};
