import React from 'react';
import {
  SinglePlaylistType,
  PlaylistContextInterface,
  InitConfig,
} from './PlaylistContext';

export const usePlaylist = (): PlaylistContextInterface => {
  const [playlist, _setPlaylist] = React.useState<SinglePlaylistType[]>(
    InitConfig
  );
  const setPlaylist = React.useCallback((currentPlaylist: []): void => {
    _setPlaylist(currentPlaylist);
  }, []);

  return {
    playlist,
    setPlaylist,
  };
};
