import React, { useState } from "react"; import PropTypes from "prop-types"; import Dropdown from "react-bootstrap/Dropdown"; export const SubtitlesButton = ({ subtitles, inLibrary, searching, search, }) => { if (inLibrary === false) { return null; } /* eslint-disable */ const [show, setShow] = useState(false); /* eslint-enable */ const onSelect = (eventKey) => { if (eventKey === null || eventKey != 1) { setShow(false); } }; const onToggle = (isOpen, event, metadata) => { // Don't close on select if (metadata && metadata.source !== "select") { setShow(isOpen); } }; const count = subtitles && subtitles.length !== 0 ? subtitles.length : 0; return ( Subtitles {count} Automatic search {count > 0 && ( Available subtitles )} {count > 0 && subtitles.map((subtitle, index) => ( {subtitle.language.split("_")[1]} ))} ); }; SubtitlesButton.propTypes = { subtitles: PropTypes.array, inLibrary: PropTypes.bool.isRequired, searching: PropTypes.bool.isRequired, search: PropTypes.func.isRequired, };