{"size": 1009, "ext": "js", "max_stars_repo_path": "client/src/reducers/notification.js", "max_stars_repo_name": "oguzhanturgut/hackyoursocial", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/src/reducers/notification.js", "max_issues_repo_name": "oguzhanturgut/hackyoursocial", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/src/reducers/notification.js", "max_forks_repo_name": "oguzhanturgut/hackyoursocial", "max_forks_repo_forks_event_min_datetime": "2020-04-20T22:43:40.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-20T22:43:40.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 21.4680851064, "max_line_length": 96, "alphanum_fraction": 0.6025768087}
import {
  GET_NOTIFICATIONS,
  NOTIFICATIONS_ERROR,
  DELETE_NOTIFICATION,
  UPDATE_NOTIFICATION,
} from '../actions/types';

const initialState = {
  notifications: [],
  notification: null,
  loading: true,
  error: {},
};

export default function(state = initialState, action) {
  const { type, payload } = action;

  switch (type) {
    case GET_NOTIFICATIONS:
      return {
        ...state,
        notifications: payload,
        loading: false,
      };
    case DELETE_NOTIFICATION:
      return {
        ...state,
        notifications: state.notifications.filter(notification => notification._id !== payload),
        loading: false,
      };
    case UPDATE_NOTIFICATION:
      return {
        ...state,
        notifications: state.notifications.filter(notification => notification._id !== payload),
        loading: false,
      };
    case NOTIFICATIONS_ERROR:
      return {
        ...state,
        error: payload,
        loading: false,
      };
    default:
      return state;
  }
}
