diff --git a/src/pages/components/item-info/globalstats/watchtimestats.jsx b/src/pages/components/item-info/globalstats/watchtimestats.jsx index 0329431..b7f95c7 100644 --- a/src/pages/components/item-info/globalstats/watchtimestats.jsx +++ b/src/pages/components/item-info/globalstats/watchtimestats.jsx @@ -3,23 +3,19 @@ import i18next from "i18next"; import { Trans } from "react-i18next"; function WatchTimeStats(props) { - function formatTime(totalSeconds, numberClassName, labelClassName) { const units = [ - { label: i18next.t("UNITS.DAY"), seconds: 86400 }, - { label: i18next.t("UNITS.HOUR"), seconds: 3600 }, - { label: i18next.t("UNITS.MINUTE"), seconds: 60 }, + { label: "UNITS.DAY", seconds: 86400 }, + { label: "UNITS.HOUR", seconds: 3600 }, + { label: "UNITS.MINUTE", seconds: 60 }, ]; - + const parts = units.reduce((result, { label, seconds }) => { const value = Math.floor(totalSeconds / seconds); if (value) { const formattedValue =

{value}

; - const formattedLabel = ( - - {value === 1 ? label : i18next.t(`UNITS.${label.toUpperCase()}S`) } - - ); + const labelPlural = label.toUpperCase() + "S"; + const formattedLabel = {value === 1 ? i18next.t(label) : i18next.t(labelPlural)}; result.push( {formattedValue} {formattedLabel} @@ -29,20 +25,20 @@ function WatchTimeStats(props) { } return result; }, []); - + if (parts.length === 0) { return ( <> -

0

{' '} -

+

0

{" "} +

+ +

); } - + return parts; } - - return (
@@ -51,11 +47,12 @@ function WatchTimeStats(props) {
-

{props.data.Plays || 0}

-

/

- - <>{formatTime(props.data.total_playback_duration || 0,'stat-value','stat-unit')} +

{props.data.Plays || 0}

+

+ / +

+ <>{formatTime(props.data.total_playback_duration || 0, "stat-value", "stat-unit")}
);