canape/frontend/js/components/admins/torrentsStat.js

22 lines
541 B
JavaScript

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