40 lines
1.0 KiB
JavaScript

import React from "react";
import PropTypes from "prop-types";
import { useDispatch } from "react-redux";
import { List } from "immutable";
import { getEpisodeDetails } from "../../../actions/shows";
import { TorrentsButton } from "../../buttons/torrents";
import { prettyEpisodeName } from "../../../utils";
export const EpisodeTorrentsButton = ({
torrents,
imdbId,
season,
episode,
showName,
searching,
}) => {
const dispatch = useDispatch();
return (
<TorrentsButton
torrents={torrents}
searching={searching}
search={() => dispatch(getEpisodeDetails(imdbId, season, episode))}
url={`#/torrents/search/shows/${encodeURI(
prettyEpisodeName(showName, season, episode)
)}`}
/>
);
};
EpisodeTorrentsButton.propTypes = {
torrents: PropTypes.instanceOf(List),
showName: PropTypes.string.isRequired,
imdbId: PropTypes.string.isRequired,
episode: PropTypes.number.isRequired,
season: PropTypes.number.isRequired,
searching: PropTypes.bool.isRequired,
};