Files
Checkmate/client/src/Components/v2/Monitors/HeaderRange.tsx
T

62 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-10-07 15:46:09 -07:00
import Stack from "@mui/material/Stack";
import { ButtonGroup, Button } from "@/Components/v2/Inputs";
import { useTheme } from "@mui/material/styles";
import Typography from "@mui/material/Typography";
2025-10-08 13:44:41 -07:00
import { useMediaQuery } from "@mui/material";
2025-10-07 15:46:09 -07:00
export const HeaderRange = ({
range,
setRange,
loading,
}: {
range: string;
setRange: Function;
loading: boolean;
}) => {
const theme = useTheme();
2025-10-08 13:44:41 -07:00
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
2025-10-07 15:46:09 -07:00
return (
<Stack
gap={theme.spacing(9)}
2025-10-08 13:44:41 -07:00
direction={isSmall ? "column" : "row"}
2025-10-07 15:46:09 -07:00
alignItems={"center"}
justifyContent="flex-end"
>
<Typography variant="body2">{`Showing statistics for past ${range}`}</Typography>
<ButtonGroup
2025-10-08 13:44:41 -07:00
orientation={isSmall ? "vertical" : "horizontal"}
fullWidth={isSmall}
2025-10-07 15:46:09 -07:00
variant="contained"
color={"primary"}
>
<Button
color={range === "2h" ? "secondary" : "inherit"}
onClick={() => setRange("2h")}
loading={loading}
>
Recent
</Button>
<Button
color={range === "24h" ? "secondary" : "inherit"}
onClick={() => setRange("24h")}
loading={loading}
>
Day
</Button>
<Button
color={range === "7d" ? "secondary" : "inherit"}
onClick={() => setRange("7d")}
loading={loading}
>
7 days
</Button>
<Button
color={range === "30d" ? "secondary" : "inherit"}
onClick={() => setRange("30d")}
loading={loading}
>
30 days
</Button>
</ButtonGroup>
</Stack>
);
};