From eae4598c8826c17c47f0eb24b3bad9341ef6914a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Delattre?= Date: Mon, 24 Jun 2019 14:51:43 +0200 Subject: [PATCH] Add a prettier runtime string for movies --- frontend/js/components/list/details.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/js/components/list/details.js b/frontend/js/components/list/details.js index 04ee2be..4670db8 100644 --- a/frontend/js/components/list/details.js +++ b/frontend/js/components/list/details.js @@ -47,14 +47,22 @@ ListDetails.propTypes = { export default ListDetails; const Runtime = (props) => { - if (props.runtime === undefined) { + if (props.runtime === undefined || props.runtime === 0) { 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 (

-  {props.runtime} min +  {duration}

); }