From c6d82223f9523c1359e5a7386b5fadd4abcf8f95 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Wed, 20 May 2026 12:02:32 -0700 Subject: [PATCH] add tags to filters --- .../Components/monitors/ControlsFilter.tsx | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/client/src/Components/monitors/ControlsFilter.tsx b/client/src/Components/monitors/ControlsFilter.tsx index a617d454c..6cb60c935 100644 --- a/client/src/Components/monitors/ControlsFilter.tsx +++ b/client/src/Components/monitors/ControlsFilter.tsx @@ -1,9 +1,11 @@ import Stack from "@mui/material/Stack"; -import { Select, Button } from "@/Components/inputs"; +import { Select, Autocomplete, Button, TextField } from "@/Components/inputs"; +import { ColoredLabel } from "@/Components/design-elements"; import MenuItem from "@mui/material/MenuItem"; import useMediaQuery from "@mui/material/useMediaQuery"; import type { MonitorType } from "@/Types/Monitor"; +import type { Tag } from "@/Types/Tag"; import { Typography, useTheme } from "@mui/material"; import { useTranslation } from "react-i18next"; @@ -28,6 +30,9 @@ export const ControlsFilter = ({ setSelectedStatus, selectedState, setSelectedState, + tagOptions, + selectedTags, + setSelectedTags, onClearFilters, }: { showTypes?: boolean; @@ -37,13 +42,22 @@ export const ControlsFilter = ({ setSelectedStatus: React.Dispatch>; selectedState: string; setSelectedState: React.Dispatch>; + tagOptions?: Tag[]; + selectedTags?: string[]; + setSelectedTags?: React.Dispatch>; onClearFilters: () => void; }) => { const theme = useTheme(); const { t } = useTranslation(); const isSmall = useMediaQuery(theme.breakpoints.down("md")); const isFilterActive = - (selectedTypes?.length ?? 0) > 0 || selectedStatus !== "" || selectedState !== ""; + (selectedTypes?.length ?? 0) > 0 || + selectedStatus !== "" || + selectedState !== "" || + (selectedTags?.length ?? 0) > 0; + const selectedTagObjects = (tagOptions ?? []).filter((tag) => + (selectedTags ?? []).includes(tag.id) + ); return ( ))} + {tagOptions && setSelectedTags && ( + option.name} + onChange={(_: unknown, newValue: Tag[]) => { + setSelectedTags(newValue.map((tag) => tag.id)); + }} + isOptionEqualToValue={(option, value) => option.id === value.id} + renderOptionContent={(option) => ( + + )} + renderInput={(params) => ( + + )} + slotProps={{ + popper: { + sx: { width: "fit-content !important", minWidth: 280 }, + }, + }} + sx={{ minWidth: 180 }} + /> + )} {isFilterActive && (