fitlers
This commit is contained in:
1 parent
83b628c8f9
commit
6063532c79
4 files changed
+117
-30
No files matched your search
@@ -0,0 +1,81 @@
|
||||
import Stack from "@mui/material/Stack";
|
||||
import { Select, Button } from "@/Components/v2/inputs";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import useMediaQuery from "@mui/material/useMediaQuery";
|
||||
import { Typography, useTheme } from "@mui/material";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { Monitor } from "@/Types/Monitor";
|
||||
|
||||
const resolutionTypes = ["manual", "automatic"];
|
||||
|
||||
interface ControlsIncidentFilterProps {
|
||||
monitors?: Monitor[];
|
||||
selectedMonitor: string;
|
||||
setSelectedMonitor: React.Dispatch<React.SetStateAction<string>>;
|
||||
selectedResolutionType: string;
|
||||
setSelectedResolutionType: React.Dispatch<React.SetStateAction<string>>;
|
||||
onClearFilters: () => void;
|
||||
}
|
||||
|
||||
export const ControlsIncidentFilter = ({
|
||||
monitors,
|
||||
selectedMonitor,
|
||||
setSelectedMonitor,
|
||||
selectedResolutionType,
|
||||
setSelectedResolutionType,
|
||||
onClearFilters,
|
||||
}: ControlsIncidentFilterProps) => {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
||||
const isFilterActive = selectedMonitor !== "0" || selectedResolutionType !== "";
|
||||
|
||||
return (
|
||||
<Stack
|
||||
direction={isSmall ? "column" : "row"}
|
||||
gap={theme.spacing(2)}
|
||||
>
|
||||
<Select
|
||||
placeholder={t("pages.incidents.filters.monitor")}
|
||||
value={selectedMonitor}
|
||||
onChange={(e) => setSelectedMonitor(e.target.value)}
|
||||
>
|
||||
<MenuItem value="0">
|
||||
<Typography>{t("pages.incidents.filters.allMonitors")}</Typography>
|
||||
</MenuItem>
|
||||
{monitors?.map((monitor) => (
|
||||
<MenuItem
|
||||
key={monitor.id}
|
||||
value={monitor.id}
|
||||
>
|
||||
<Typography>{monitor.name}</Typography>
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
placeholder={t("pages.incidents.filters.resolutionType")}
|
||||
value={selectedResolutionType}
|
||||
onChange={(e) => setSelectedResolutionType(e.target.value)}
|
||||
>
|
||||
{resolutionTypes.map((type) => (
|
||||
<MenuItem
|
||||
key={type}
|
||||
value={type}
|
||||
>
|
||||
<Typography textTransform="capitalize">
|
||||
{t(`pages.incidents.filters.resolutionTypes.${type}`)}
|
||||
</Typography>
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
{isFilterActive && (
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={onClearFilters}
|
||||
>
|
||||
{t("pages.incidents.filters.clearFilters")}
|
||||
</Button>
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
@@ -18,6 +18,7 @@ import { useTheme } from "@mui/material/styles";
|
||||
import Box from "@mui/material/Box";
|
||||
|
||||
interface IncidentsTableProps {
|
||||
title?: string;
|
||||
incidents?: Incident[];
|
||||
monitors?: Monitor[];
|
||||
incidentsCount: number;
|
||||
@@ -30,7 +31,6 @@ interface IncidentsTableProps {
|
||||
}
|
||||
|
||||
export const IncidentsTable = ({
|
||||
title,
|
||||
incidents,
|
||||
monitors,
|
||||
incidentsCount,
|
||||
|
||||
Reference in new issue
Block a user