diff --git a/web/src/screens/settings/Irc.tsx b/web/src/screens/settings/Irc.tsx index fd5cb3c..9e0df98 100644 --- a/web/src/screens/settings/Irc.tsx +++ b/web/src/screens/settings/Irc.tsx @@ -6,7 +6,7 @@ import { useToggle } from "../../hooks/hooks"; import { APIClient } from "../../api/APIClient"; import { EmptySimple } from "../../components/emptystates"; import { LockClosedIcon, LockOpenIcon } from "@heroicons/react/24/solid"; -import { Menu, Transition } from "@headlessui/react"; +import { Menu, Switch, Transition } from "@headlessui/react"; import { Fragment, useRef } from "react"; import { DeleteModal } from "../../components/modals"; @@ -35,8 +35,8 @@ export const IrcSettings = () => {
-
-
+
+

IRC @@ -57,8 +57,8 @@ export const IrcSettings = () => {

-
-
    +
    +
    1. { Network healthy
    2. -
    3. +
    4. { Network unhealthy
    5. -
    6. +
    7. {
    {data && data.length > 0 ? ( -
    +
    1. -
      +
      + Enabled +
      +
      Network
      -
      +
      Server
      -
      +
      Nick
    2. @@ -139,6 +142,24 @@ const ListItem = ({ idx, network, expanded }: ListItemProps) => { const [updateIsOpen, toggleUpdate] = useToggle(false); const [edit, toggleEdit] = useToggle(false); + const queryClient = useQueryClient(); + const mutation = useMutation( + (network: IrcNetwork) => APIClient.irc.updateNetwork(network), + { + onSuccess: () => { + queryClient.invalidateQueries(["networks"]); + toast.custom((t) => ); + } + } + ); + + const onToggleMutation = (newState: boolean) => { + mutation.mutate({ + ...network, + enabled: newState + }); + }; + return (
    3. @@ -147,9 +168,27 @@ const ListItem = ({ idx, network, expanded }: ListItemProps) => { toggle={toggleUpdate} network={network} /> - +
      + + Enable + +
      @@ -175,13 +214,13 @@ const ListItem = ({ idx, network, expanded }: ListItemProps) => { )} -
      +
      {network.name}
      { )} /> )}
      -

      +

      {network.server}:{network.port}

      -
      +
      {network.nick}
      @@ -239,7 +278,7 @@ const ListItem = ({ idx, network, expanded }: ListItemProps) => { {network.channels.map((c) => (
    4. -
      +
      {network.enabled ? ( c.monitoring ? ( @@ -259,12 +298,12 @@ const ListItem = ({ idx, network, expanded }: ListItemProps) => { {c.name}
      -
      +
      {IsEmptyDate(c.monitoring_since)}
      -
      +
      {IsEmptyDate(c.last_announce)} @@ -360,7 +399,7 @@ const ListItemDropdown = ({ leaveTo="transform opacity-0 scale-95" >