Grégoire Delattre 4b26080193
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
Update redux state management
Use immer with native javascript objects instead of immutablejs.
2020-04-07 18:22:26 +02:00

27 lines
662 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.isRequired,
torrentCount: PropTypes.number.isRequired,
torrentCountById: PropTypes.number.isRequired,
};
TorrentsStat.defaultProps = {
count: 1,
torrentCount: 0,
torrentCountById: 0,
};