import { faSearch, faTrash } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import React, { FunctionComponent } from "react"; import { Badge } from "react-bootstrap"; import { useSerieBy } from "../../@redux/hooks"; import { EpisodesApi } from "../../apis"; import { AsyncButton, LanguageText } from "../../components"; interface Props { seriesid: number; episodeid: number; missing?: boolean; subtitle: Subtitle; } export const SubtitleAction: FunctionComponent = ({ seriesid, episodeid, missing, subtitle, }) => { const { hi, forced } = subtitle; const [, update] = useSerieBy(seriesid); const path = subtitle.path; if (missing || path) { return ( { if (missing) { return EpisodesApi.downloadSubtitles(seriesid, episodeid, { hi, forced, language: subtitle.code2, }); } else if (path) { return EpisodesApi.deleteSubtitles(seriesid, episodeid, { hi, forced, path: path, language: subtitle.code2, }); } else { return null; } }} onSuccess={update} as={Badge} className="mr-1" variant={missing ? "primary" : "secondary"} > ); } else { return ( ); } };