fix uptime chart legends, set initial loading state to true to avoid extra render

This commit is contained in:
Alex Holliday committed 2025-01-31 13:45:07 -08:00
1 parent 49c58ce2ae
commit f218b60591
2 files changed
+23 -21

No files matched your search

@@ -41,6 +41,7 @@ const ChartBoxes = ({
header="Uptime" header="Uptime"
> >
<Stack <Stack
width={"100%"}
justifyContent="space-between" justifyContent="space-between"
direction="row" direction="row"
> >
@@ -93,26 +94,28 @@ const ChartBoxes = ({
icon={<IncidentsIcon />} icon={<IncidentsIcon />}
header="Incidents" header="Incidents"
> >
<Box position="relative"> <Stack width={"100%"}>
<Typography component="span"> <Box position="relative">
{hoveredIncidentsData !== null <Typography component="span">
? hoveredIncidentsData.totalChecks {hoveredIncidentsData !== null
: (monitor?.groupedDownChecks?.reduce((count, checkGroup) => { ? hoveredIncidentsData.totalChecks
return count + checkGroup.totalChecks; : (monitor?.groupedDownChecks?.reduce((count, checkGroup) => {
}, 0) ?? 0)} return count + checkGroup.totalChecks;
</Typography> }, 0) ?? 0)}
{hoveredIncidentsData !== null && hoveredIncidentsData.time !== null && (
<Typography
component="h5"
position="absolute"
top="100%"
fontSize={11}
color={theme.palette.primary.contrastTextTertiary}
>
{formatDateWithTz(hoveredIncidentsData._id, dateFormat, uiTimezone)}
</Typography> </Typography>
)} {hoveredIncidentsData !== null && hoveredIncidentsData.time !== null && (
</Box> <Typography
component="h5"
position="absolute"
top="100%"
fontSize={11}
color={theme.palette.primary.contrastTextTertiary}
>
{formatDateWithTz(hoveredIncidentsData._id, dateFormat, uiTimezone)}
</Typography>
)}
</Box>
</Stack>
<DownBarChart <DownBarChart
monitor={monitor} monitor={monitor}
type={dateRange} type={dateRange}
@@ -4,14 +4,13 @@ import { logger } from "../../../../Utils/Logger";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
export const useMonitorFetch = ({ authToken, monitorId, dateRange }) => { export const useMonitorFetch = ({ authToken, monitorId, dateRange }) => {
const [monitorIsLoading, setMonitorsIsLoading] = useState(false); const [monitorIsLoading, setMonitorsIsLoading] = useState(true);
const [monitor, setMonitor] = useState(undefined); const [monitor, setMonitor] = useState(undefined);
const navigate = useNavigate(); const navigate = useNavigate();
useEffect(() => { useEffect(() => {
const fetchMonitors = async () => { const fetchMonitors = async () => {
try { try {
setMonitorsIsLoading(true);
const res = await networkService.getUptimeDetailsById({ const res = await networkService.getUptimeDetailsById({
authToken: authToken, authToken: authToken,
monitorId: monitorId, monitorId: monitorId,