import { useToggle } from "../../hooks/hooks"; import { useMutation, useQuery, useQueryClient } from "react-query"; import { APIClient } from "../../api/APIClient"; import { Menu, Switch, Transition } from "@headlessui/react"; import { classNames } from "../../utils"; import { Fragment, useRef, useState } from "react"; import { toast } from "react-hot-toast"; import Toast from "../../components/notifications/Toast"; import { queryClient } from "../../App"; import { DeleteModal } from "../../components/modals"; import { DotsHorizontalIcon, PencilAltIcon, SwitchHorizontalIcon, TrashIcon } from "@heroicons/react/outline"; import { FeedUpdateForm } from "../../forms/settings/FeedForms"; import { EmptySimple } from "../../components/emptystates"; import { componentMapType } from "../../forms/settings/DownloadClientForms"; function FeedSettings() { const { data } = useQuery( "feeds", () => APIClient.feeds.find(), { refetchOnWindowFocus: false } ); return (

Feeds

Manage Torznab feeds.

{data && data.length > 0 ?
  1. Enabled
    Name
    Type
    {/*
    Events
    */}
  2. {data && data.map((f) => ( ))}
: }
); } const ImplementationTorznab = () => ( Torznab ); export const ImplementationMap: componentMapType = { "TORZNAB": }; interface ListItemProps { feed: Feed; } function ListItem({ feed }: ListItemProps) { const [updateFormIsOpen, toggleUpdateForm] = useToggle(false); const [enabled, setEnabled] = useState(feed.enabled); const updateMutation = useMutation( (status: boolean) => APIClient.feeds.toggleEnable(feed.id, status), { onSuccess: () => { toast.custom((t) => ); queryClient.invalidateQueries(["feeds"]); queryClient.invalidateQueries(["feeds", feed?.id]); } } ); const toggleActive = (status: boolean) => { setEnabled(status); updateMutation.mutate(status); }; return (
  • Use setting
    {feed.name}
    {ImplementationMap[feed.type]}
  • ); } interface FeedItemDropdownProps { feed: Feed; onToggle: (newState: boolean) => void; toggleUpdate: () => void; } const FeedItemDropdown = ({ feed, onToggle, toggleUpdate }: FeedItemDropdownProps) => { const cancelModalButtonRef = useRef(null); const queryClient = useQueryClient(); const [deleteModalIsOpen, toggleDeleteModal] = useToggle(false); const deleteMutation = useMutation( (id: number) => APIClient.feeds.delete(id), { onSuccess: () => { queryClient.invalidateQueries(["feeds"]); queryClient.invalidateQueries(["feeds", feed.id]); toast.custom((t) => ); } } ); return ( { deleteMutation.mutate(feed.id); toggleDeleteModal(); }} title={`Remove feed: ${feed.name}`} text="Are you sure you want to remove this feed? This action cannot be undone." />
    {({ active }) => ( )} {({ active }) => ( )}
    {({ active }) => ( )}
    ); }; export default FeedSettings;