/* * Copyright (c) 2021 - 2024, Ludvig Lundgren and the autobrr contributors. * SPDX-License-Identifier: GPL-2.0-or-later */ import { useMutation, useQueryClient, useSuspenseQuery } from "@tanstack/react-query"; import { PlusIcon } from "@heroicons/react/24/solid"; import { useToggle } from "@hooks/hooks"; import { APIClient } from "@api/APIClient"; import { ListKeys } from "@api/query_keys"; import { toast } from "@components/hot-toast"; import Toast from "@components/notifications/Toast"; import { Checkbox } from "@components/Checkbox"; import { ListsQueryOptions } from "@api/queries"; import { Section } from "@screens/settings/_components"; import { EmptySimple } from "@components/emptystates"; import { ListAddForm, ListUpdateForm } from "@forms"; import { FC } from "react"; import { Link } from "@tanstack/react-router"; function ListsSettings() { const [addFormIsOpen, toggleAddList] = useToggle(false); const listsQuery = useSuspenseQuery(ListsQueryOptions()) const lists = listsQuery.data return ( Lists can automatically update your filters from arrs or other sources. > } rightSide={ Add new } > {lists.length ? ( Enabled Name Filters Type {lists.map((list) => ( ))} ) : ( )} ); } interface FilterPillProps { filter: ListFilter; } const FilterPill: FC = ({ filter }) => ( {filter.name} ); export default ListsSettings; interface ListItemProps { list: List; } function ListItem({ list }: ListItemProps) { const [isOpen, toggleUpdate] = useToggle(false); const queryClient = useQueryClient(); const updateMutation = useMutation({ mutationFn: (req: List) => APIClient.lists.update(req), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ListKeys.lists() }); toast.custom(t => ); }, onError: () => { toast.custom((t) => ); } }); const onToggleMutation = (newState: boolean) => { updateMutation.mutate({ ...list, enabled: newState }); }; return ( {list.name} {/*{list.filters.map(filter => )}*/} {list.type} Edit ); } interface ListItemFiltersProps { filters: ListFilter[]; } const ListItemFilters = ({ filters }: ListItemFiltersProps) => { if (!filters.length) { return null; } const res = filters.slice(2); return ( {filters.length > 1 ? ( ) : null} {filters.length > 2 ? ( v.name).toString()} > +{filters.length - 2} ) : null} ); }