import React from "react";
import PropTypes from "prop-types";
export const TorrentsStat = ({ count, torrentCount, torrentCountById }) => {
if (torrentCount === undefined) {
return No torrents;
}
const percentage = Math.floor((torrentCountById * 100) / count);
return (
{percentage}% with torrents
- {torrentCount} total
);
};
TorrentsStat.propTypes = {
count: PropTypes.number.isRequired,
torrentCount: PropTypes.number.isRequired,
torrentCountById: PropTypes.number.isRequired,
};
TorrentsStat.defaultProps = {
count: 1,
torrentCount: 0,
torrentCountById: 0,
};