Files
Checkmate/client/src/Pages/Settings/DummyChart.tsx
T

61 lines
1.5 KiB
TypeScript
Raw Normal View History

2026-01-24 00:51:13 +00:00
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import { useTheme } from "@mui/material/styles";
2026-02-20 18:13:39 +00:00
import { HeatmapResponseTime, HistogramResponseTime } from "@/Components/common";
2026-01-27 19:50:32 +00:00
import type { CheckSnapshot } from "@/Types/Check";
2026-01-24 00:51:13 +00:00
interface DummyChartProps {
chartType: string;
}
2026-01-27 19:50:32 +00:00
const generateDummyChecks = (): CheckSnapshot[] => {
const checks: CheckSnapshot[] = [];
2026-01-24 00:51:13 +00:00
for (let i = 0; i < 25; i++) {
const isUp = Math.random() > 0.1;
2026-02-03 23:30:23 +00:00
const responseTime = Math.floor(Math.random() * 80) + 20;
2026-01-24 00:51:13 +00:00
checks.push({
id: `dummy-${i}`,
status: isUp,
statusCode: isUp ? 200 : 500,
2026-02-03 23:30:23 +00:00
responseTime: responseTime,
originalResponseTime: responseTime,
2026-01-24 00:51:13 +00:00
message: "",
createdAt: new Date(Date.now() - i * 60000).toISOString(),
});
}
return checks;
};
const dummyChecks = generateDummyChecks();
const DummyChart = ({ chartType }: DummyChartProps) => {
const theme = useTheme();
return (
<Box
sx={{
mt: theme.spacing(4),
p: theme.spacing(4),
border: 1,
borderColor: theme.palette.divider,
borderRadius: theme.shape.borderRadius,
backgroundColor: theme.palette.background.paper,
}}
>
<Typography
variant="body2"
color="text.secondary"
sx={{ mb: theme.spacing(2) }}
>
Preview
</Typography>
{chartType === "histogram" ? (
<HistogramResponseTime checks={dummyChecks} />
) : (
<HeatmapResponseTime checks={dummyChecks} />
)}
</Box>
);
};
export default DummyChart;