import * as actions from "../constants/actions/index";

const initialState = { tracks: [], currentTrack: {} };

export default (state = initialState, { type, tracks, trackIndex }) => {
  switch (type) {
    case actions.SET_TRACKS:
      return {
        ...state,
        tracks,
      };

    case actions.SET_CURRENT_TRACK:
      return {
        ...state,
        currentTrack: trackIndex,
      };

    case actions.CLEAR_TRACK_LIST:
      return {
        ...state,
        currentTrack: {},
        tracks: [],
      };

    default:
      return { ...state };
  }
};
