Merge pull request #2480 from bluewave-labs/fix/time-format

fix: update time format function, resolves #2477
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-06-18 09:44:20 +08:00
commit 8d30de1ff8
3 files changed
+35 -37

No files matched your search

@@ -5,13 +5,8 @@ import { getHumanReadableDuration } from "../../../../../Utils/timeUtils";
import { useTranslation } from "react-i18next";
const PageSpeedStatusBoxes = ({ shouldRender, monitor }) => {
const { time: uptimeDuration, units: uptimeUnits } = getHumanReadableDuration(
monitor?.uptimeDuration
);
const { time: lastCheckTime, units: lastCheckUnits } = getHumanReadableDuration(
monitor?.lastChecked
);
const uptimeDuration = getHumanReadableDuration(monitor?.uptimeDuration);
const time = getHumanReadableDuration(monitor?.lastChecked);
const { t } = useTranslation();
@@ -22,7 +17,6 @@ const PageSpeedStatusBoxes = ({ shouldRender, monitor }) => {
subHeading={
<>
{uptimeDuration}
<Typography component="span">{uptimeUnits}</Typography>
<Typography component="span">{t("ago")}</Typography>
</>
}
@@ -31,8 +25,7 @@ const PageSpeedStatusBoxes = ({ shouldRender, monitor }) => {
heading="last check"
subHeading={
<>
{lastCheckTime}
<Typography component="span">{lastCheckUnits}</Typography>
{time}
<Typography component="span">{t("ago")}</Typography>
</>
}
@@ -24,30 +24,22 @@ const UptimeStatusBoxes = ({
const timeOfLastCheck = monitorStats?.lastCheckTimestamp;
const timeSinceLastCheck = Date.now() - timeOfLastCheck;
const { time: streakTime, units: streakUnits } =
getHumanReadableDuration(timeSinceLastFailure);
const streakTime = getHumanReadableDuration(timeSinceLastFailure);
const { time: lastCheckTime, units: lastCheckUnits } =
getHumanReadableDuration(timeSinceLastCheck);
const lastCheckTime = getHumanReadableDuration(timeSinceLastCheck);
return (
<StatusBoxes shouldRender={!isLoading}>
<StatBox
gradient={true}
status={determineState(monitor)}
heading={"active for"}
subHeading={
<>
{streakTime}
<Typography component="span">{streakUnits}</Typography>
</>
}
subHeading={streakTime}
/>
<StatBox
heading="last check"
subHeading={
<>
{lastCheckTime}
<Typography component="span">{lastCheckUnits}</Typography>
<Typography component="span">{"ago"}</Typography>
</>
}
@@ -80,7 +72,7 @@ const UptimeStatusBoxes = ({
};
UptimeStatusBoxes.propTypes = {
shouldRender: PropTypes.bool,
isLoading: PropTypes.bool,
monitor: PropTypes.object,
monitorStats: PropTypes.object,
certificateExpiry: PropTypes.string,