cpLoginReducer.js 511 Bytes
import { LOGIN_SUCCESS, LOGIN_FAIL, CLEAR_ERRORS } from "../constants/cpLoginConstants";

// Room details reducer.
export const cpLoginReducer = (state = { cpLogin: {} }, action) => {
  switch (action.type) {
    case LOGIN_SUCCESS:
      return {
        cpLogin: action.payload.data
      };

    case LOGIN_FAIL:
      return {
        error: action.payload.error.message
      };

    case CLEAR_ERRORS:
      return {
        ...state,
        error: null
      };

    default:
      return state;
  }
};