import React, { createContext, useContext } from 'react';

interface PlaylistActionsContextValue {
  onRemoveFromPlaylist?: () => void;
}

const PlaylistActionsContext = createContext<
  PlaylistActionsContextValue | undefined
>(undefined);

export const PlaylistActionsProvider: React.FC<{
  children: React.ReactNode;
  onRemoveFromPlaylist?: () => void;
}> = ({ children, onRemoveFromPlaylist }) => {
  return (
    <PlaylistActionsContext.Provider value={{ onRemoveFromPlaylist }}>
      {children}
    </PlaylistActionsContext.Provider>
  );
};

export const usePlaylistActions = () => {
  const context = useContext(PlaylistActionsContext);
  // Return null object if not in a playlist context
  return context || { onRemoveFromPlaylist: undefined };
};
