Skip to content

Commit ca9ed0b

Browse files
committed
Refactor ScheduleInfo to calculate and display next run time; replace parseUtcDate with calculateNextRunTime
1 parent 2f1475d commit ca9ed0b

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

src/octockup.client/src/components/ScheduleCard.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ import { BackupStatus } from "../types/api";
2424
import { confirm } from "material-ui-confirm";
2525
import { useTranslation } from "react-i18next";
2626
import type { ScheduleItem, ScheduleReport } from "../types/api";
27-
import { parseUtcDate } from "../utils/dateUtils";
2827
import { formatSpeed, formatElapsed } from "../utils/formatUtils";
29-
import { formatNextRun, formatInterval } from "../utils/scheduleUtils";
28+
import {
29+
calculateNextRunTime,
30+
formatNextRun,
31+
formatInterval,
32+
} from "../utils/scheduleUtils";
3033
import { getSourceIcon } from "../constants/sourceIcons";
3134

3235
function getStatusIcon(status: BackupStatus) {
@@ -202,6 +205,7 @@ function ScheduleInfo({
202205
progress: number;
203206
}) {
204207
const { t } = useTranslation();
208+
const nextRun = calculateNextRunTime(item);
205209

206210
const renderIntervalInfo = () => {
207211
if (!item.interval) {
@@ -251,12 +255,18 @@ function ScheduleInfo({
251255
</Typography>
252256
</Box>
253257
)}
254-
<Typography
255-
variant="caption"
256-
sx={{ color: "text.secondary", display: "block", fontSize: "0.7rem" }}
257-
>
258-
{parseUtcDate(item.startAt)!.toLocaleString()}
259-
</Typography>
258+
{nextRun && (
259+
<Typography
260+
variant="caption"
261+
sx={{
262+
color: "text.secondary",
263+
display: "block",
264+
fontSize: "0.7rem",
265+
}}
266+
>
267+
{nextRun.toLocaleString()}
268+
</Typography>
269+
)}
260270
</Box>
261271
</Box>
262272
);

0 commit comments

Comments
 (0)