import { useTranslation } from "next-i18next"; import Container from "components/services/widget/container"; import Block from "components/services/widget/block"; import useWidgetAPI from "utils/proxy/use-widget-api"; const processUptime = uptime => { let seconds = uptime.toFixed(0); var levels = [ [Math.floor(seconds / 31536000), 'year'], [Math.floor((seconds % 31536000) / 2592000), 'month'], [Math.floor(((seconds % 31536000) % 2592000) / 86400), 'day'], [Math.floor(((seconds % 31536000) % 86400) / 3600), 'hour'], [Math.floor((((seconds % 31536000) % 86400) % 3600) / 60), 'minute'], [(((seconds % 31536000) % 86400) % 3600) % 60, 'second'], ]; for(let i = 0; i< levels.length; i++){ let level = levels[i]; if(level[0] > 0){ return { value: level[0], unit: level[1] } } } return { value: 0, unit: 'second' }; } export default function Component({ service }) { const { t } = useTranslation(); const { widget } = service; const { data: alertData, error: alertError } = useWidgetAPI(widget, "alerts"); const { data: statusData, error: statusError } = useWidgetAPI(widget, "status"); if (alertError || statusError) { return ; } if (!alertData || !statusData) { return ( ); } return ( ); }