Files
Checkmate/client/src/Pages/DistributedUptime/Details/Components/DistributedUptimeResponseChart/index.jsx
T

53 lines
1.4 KiB
React
Raw Normal View History

2025-02-13 14:49:03 -08:00
//Components
import { Stack, Switch, Typography } from "@mui/material";
import { useState } from "react";
import DistributedUptimeResponseAreaChart from "./Area";
import DistributedUptimeResponseBarChart from "./Bar";
2025-02-06 16:07:57 -08:00
import ChartBox from "../../../../../Components/Charts/ChartBox";
import ResponseTimeIcon from "../../../../../assets/icons/response-time-icon.svg?react";
2025-02-05 14:59:08 -08:00
2025-02-13 14:49:03 -08:00
// Utils
import PropTypes from "prop-types";
import { useTranslation } from "react-i18next";
2025-02-05 14:59:08 -08:00
const DistributedUptimeResponseChart = ({ checks }) => {
2025-02-13 14:49:03 -08:00
const [chartType, setChartType] = useState("bar");
const { t } = useTranslation();
2025-02-13 14:49:03 -08:00
let Chart = null;
if (chartType === "area") {
Chart = DistributedUptimeResponseAreaChart;
}
if (chartType === "bar") {
Chart = DistributedUptimeResponseBarChart;
}
2025-02-05 14:59:08 -08:00
return (
2025-02-13 14:49:03 -08:00
<Stack>
<Stack
direction="row"
alignItems="center"
>
<Typography>{t("bar")}</Typography>
2025-02-13 14:49:03 -08:00
<Switch
color="main"
value={chartType}
onChange={(e) => setChartType(e.target.checked ? "area" : "bar")}
/>
<Typography>{t("area")}</Typography>
2025-02-13 14:49:03 -08:00
</Stack>
<ChartBox
icon={<ResponseTimeIcon />}
header="Response Times"
sx={{ padding: 0 }}
2025-02-05 14:59:08 -08:00
>
2025-02-13 14:49:03 -08:00
<Chart checks={checks} />
</ChartBox>
</Stack>
2025-02-05 14:59:08 -08:00
);
};
DistributedUptimeResponseChart.propTypes = {
checks: PropTypes.array,
2025-02-13 14:49:03 -08:00
type: PropTypes.string,
2025-02-05 14:59:08 -08:00
};
export default DistributedUptimeResponseChart;