Add a prettier runtime string for movies

This commit is contained in:
Grégoire Delattre 2019-06-24 14:51:43 +02:00
parent 20ca2adefc
commit eae4598c88

View File

@ -47,14 +47,22 @@ ListDetails.propTypes = {
export default ListDetails; export default ListDetails;
const Runtime = (props) => { const Runtime = (props) => {
if (props.runtime === undefined) { if (props.runtime === undefined || props.runtime === 0) {
return null; return null;
} }
const hours = Math.floor(props.runtime / 60);
const minutes = (props.runtime % 60);
let duration = "";
if (hours > 0) { duration += hours + "h" }
if (minutes > 0) { duration += ("0" + minutes).slice(-2) }
if (hours === 0) { duration += " min" }
return ( return (
<p> <p>
<i className="fa fa-clock-o"></i> <i className="fa fa-clock-o"></i>
&nbsp;{props.runtime} min &nbsp;{duration}
</p> </p>
); );
} }