mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 05:35:25 +03:00
Use existing switch component for general filter content
This commit is contained in:
parent
57873b90c0
commit
df1a10294c
@ -593,30 +593,17 @@ export function GeneralFilterContent({
|
|||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<div className="my-2.5 flex flex-col gap-2.5">
|
<div className="my-2.5 flex flex-col gap-2.5">
|
||||||
{allLabels.map((item) => (
|
{allLabels.map((item) => (
|
||||||
<div className="flex justify-between items-center">
|
<FilterSwitch
|
||||||
<Label
|
label={item.replaceAll("_", " ")}
|
||||||
className="w-full mx-2 text-primary capitalize cursor-pointer"
|
isChecked={currentLabels?.includes(item) ?? false}
|
||||||
htmlFor={item}
|
|
||||||
>
|
|
||||||
{item.replaceAll("_", " ")}
|
|
||||||
</Label>
|
|
||||||
<Switch
|
|
||||||
key={item}
|
|
||||||
className="ml-1"
|
|
||||||
id={item}
|
|
||||||
checked={currentLabels?.includes(item) ?? false}
|
|
||||||
onCheckedChange={(isChecked) => {
|
onCheckedChange={(isChecked) => {
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
const updatedLabels = currentLabels
|
const updatedLabels = currentLabels ? [...currentLabels] : [];
|
||||||
? [...currentLabels]
|
|
||||||
: [];
|
|
||||||
|
|
||||||
updatedLabels.push(item);
|
updatedLabels.push(item);
|
||||||
setCurrentLabels(updatedLabels);
|
setCurrentLabels(updatedLabels);
|
||||||
} else {
|
} else {
|
||||||
const updatedLabels = currentLabels
|
const updatedLabels = currentLabels ? [...currentLabels] : [];
|
||||||
? [...currentLabels]
|
|
||||||
: [];
|
|
||||||
|
|
||||||
// can not deselect the last item
|
// can not deselect the last item
|
||||||
if (updatedLabels.length > 1) {
|
if (updatedLabels.length > 1) {
|
||||||
@ -626,7 +613,6 @@ export function GeneralFilterContent({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user