diff --git a/Client/src/Pages/Monitors/Home/monitorData.jsx b/Client/src/Pages/Monitors/Home/monitorData.jsx index 2f176bd04..4220fc2c5 100644 --- a/Client/src/Pages/Monitors/Home/monitorData.jsx +++ b/Client/src/Pages/Monitors/Home/monitorData.jsx @@ -27,6 +27,14 @@ const data = { rows: [], }; +/** + * Builds table data for a list of monitors. + * + * @param {Array} monitors - An array of monitor objects containing information about each monitor. + * @param {boolean} isAdmin - Flag indicating if the current user is an admin. + * @param {Function} navigate - A function to navigate to the monitor detail page. + * @returns {Object} The data structure containing columns and rows for the table. + */ export const buildData = (monitors, isAdmin, navigate) => { const theme = useTheme(); @@ -34,13 +42,14 @@ export const buildData = (monitors, isAdmin, navigate) => { let uptimePercentage = ""; let percentageColor = theme.palette.percentage.green; + // Determine uptime percentage and color based on the monitor's uptimePercentage value if (monitor.uptimePercentage !== undefined) { uptimePercentage = monitor.uptimePercentage === 0 ? "0" : (monitor.uptimePercentage * 100).toFixed(2); - percentageColor = + percentageColor = monitor.uptimePercentage < 0.25 ? theme.palette.percentage.red : monitor.uptimePercentage < 0.5 @@ -58,7 +67,7 @@ export const buildData = (monitors, isAdmin, navigate) => { status: monitor.status === true ? "up" : "down", }; - // Reverse checks so latest check is on the right + // Reverse checks so the latest check is on the right const reversedChecks = monitor.checks.slice().reverse(); return { @@ -94,6 +103,3 @@ export const buildData = (monitors, isAdmin, navigate) => { }); return data; }; - - -