diff --git a/Client/src/Pages/Maintenance/MaintenanceTable/index.jsx b/Client/src/Pages/Maintenance/MaintenanceTable/index.jsx
index 6cccfa06a..ea8418cb6 100644
--- a/Client/src/Pages/Maintenance/MaintenanceTable/index.jsx
+++ b/Client/src/Pages/Maintenance/MaintenanceTable/index.jsx
@@ -27,6 +27,7 @@ import SelectorVertical from "../../../assets/icons/selector-vertical.svg?react"
import { formatDurationRounded } from "../../../Utils/timeUtils";
import { StatusLabel } from "../../../Components/Label";
import { setRowsPerPage } from "../../../Features/UI/uiSlice";
+import dayjs from "dayjs";
/**
* Component for pagination actions (first, previous, next, last).
@@ -116,6 +117,41 @@ const MaintenanceTable = ({
setPage(newPage);
};
+ const getTimeToNextWindow = (startTime, endTime, repeat) => {
+ //1. Advance time closest to next window as possible
+ const now = dayjs();
+ let start = dayjs(startTime);
+ let end = dayjs(endTime);
+ if (repeat > 0) {
+ // Advance time closest to next window as possible
+ while (start.isBefore(now) && end.isBefore(now)) {
+ start = start.add(repeat, "milliseconds");
+ end = end.add(repeat, "milliseconds");
+ }
+ }
+
+ //Check if we are in a window
+ if (now.isAfter(start) && now.isBefore(end)) {
+ return "In maintenance window";
+ }
+
+ if (start.isAfter(now)) {
+ const diffInMinutes = start.diff(now, "minutes");
+ const diffInHours = start.diff(now, "hours");
+ const diffInDays = start.diff(now, "days");
+
+ if (diffInMinutes < 60) {
+ return diffInMinutes + " minutes";
+ } else if (diffInHours < 24) {
+ return diffInHours + " hours";
+ } else if (diffInDays < 7) {
+ return diffInDays + " days";
+ } else {
+ return diffInDays + " days";
+ }
+ }
+ };
+
const handleChangeRowsPerPage = (event) => {
dispatch(
setRowsPerPage({
@@ -215,7 +251,13 @@ const MaintenanceTable = ({
customStyles={{ textTransform: "capitalize" }}
/>
- {maintenanceWindow.start}
+
+ {getTimeToNextWindow(
+ maintenanceWindow.start,
+ maintenanceWindow.end,
+ maintenanceWindow.repeat
+ )}
+
{maintenanceWindow.repeat === 0
? "N/A"