/* * Copyright (c) 2021-2025, Ludvig Lundgren and the autobrr contributors. * SPDX-License-Identifier: GPL-2.0-or-later */ import { useToggle } from "@hooks/hooks.ts"; import { useMutation, useQueryClient, useSuspenseQuery } from "@tanstack/react-query"; import { PlusIcon } from "@heroicons/react/24/solid"; import { APIClient } from "@api/APIClient"; import { ProxyKeys } from "@api/query_keys"; import { ProxiesQueryOptions } from "@api/queries"; import { Section } from "./_components"; import { EmptySimple } from "@components/emptystates"; import { Checkbox } from "@components/Checkbox"; import { ProxyAddForm, ProxyUpdateForm } from "@forms/settings/ProxyForms"; import { toast } from "@components/hot-toast"; import Toast from "@components/notifications/Toast"; interface ListItemProps { proxy: Proxy; } function ListItem({ proxy }: ListItemProps) { const [isOpen, toggleUpdate] = useToggle(false); const queryClient = useQueryClient(); const updateMutation = useMutation({ mutationFn: (req: Proxy) => APIClient.proxy.update(req), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ProxyKeys.lists() }); toast.custom(t => ); }, onError: () => { toast.custom((t) => ); } }); const onToggleMutation = (newState: boolean) => { updateMutation.mutate({ ...proxy, enabled: newState }); }; return (
  • {proxy.name}
    {proxy.type}
    Edit
  • ); } function ProxySettings() { const [addProxyIsOpen, toggleAddProxy] = useToggle(false); const proxiesQuery = useSuspenseQuery(ProxiesQueryOptions()) const proxies = proxiesQuery.data return (
    Add new } >
    {proxies.length ? (
    • sortedIndexers.requestSort("enabled")} > Enabled {/*{sortedIndexers.getSortIndicator("enabled")}*/}
      sortedIndexers.requestSort("name")} > Name {/*{sortedIndexers.getSortIndicator("name")}*/}
      sortedIndexers.requestSort("implementation")} > Type {/*{sortedIndexers.getSortIndicator("implementation")}*/}
    • {proxies.map((proxy) => ( ))}
    ) : ( )}
    ); } export default ProxySettings;