import { Map } from 'immutable';

import {
  LOGIN_SUCCESS,
  SET_PROFILE,
  UNSET_PROFILE,
  UPDATE_PROFILE,
} from '../constants/actionTypes.js';

export const profile = (state = new Map(), action) => {
  switch (action.type) {
    case LOGIN_SUCCESS:
      return action.payload.user;
    case SET_PROFILE:
      return action.payload;
    case UNSET_PROFILE:
      return new Map();
    case UPDATE_PROFILE:
      return action.payload;
    default:
      return state;
  }
};
