import { useToggle } from 'hooks'

export type Props = {
  onSelect: (quality: string) => void,
  selectedQuality: string,
  videoQualities: Array<string>,
}

export const useSettings = ({ onSelect }: Props) => {
  const {
    close,
    isOpen,
    open,
  } = useToggle()

  const onItemClick = (quality: string) => {
    onSelect(quality)
    close()
  }

  return {
    close,
    isOpen,
    onItemClick,
    open,
  }
}
