import { useQuery } from "react-query"; import { formatDistanceToNowStrict, formatISO9075 } from "date-fns"; import APIClient from "../../api/APIClient"; import { useToggle } from "../../hooks/hooks"; import { EmptySimple } from "../../components/emptystates"; import { IrcNetworkAddForm, IrcNetworkUpdateForm } from "../../forms"; function IsEmptyDate(date: string) { if (date !== "0001-01-01T00:00:00Z") { return formatDistanceToNowStrict( new Date(date), { addSuffix: true } ) } return "n/a" } function simplifyDate(date: string) { if (date !== "0001-01-01T00:00:00Z") { return formatISO9075(new Date(date)) } return "n/a" } function IrcSettings() { const [addNetworkIsOpen, toggleAddNetwork] = useToggle(false) const { data } = useQuery('networks', APIClient.irc.getNetworks, { refetchOnWindowFocus: false } ) return (

IRC

IRC networks and channels. Click on a network to view channel status.

{data && data.length > 0 ?
  1. {/*
    Enabled
    */}
    Network
    Server
    Nick
  2. {data && data.map((network: IrcNetwork, idx) => ( ))}
: }
) } interface LiItemProps { idx: number; network: IrcNetwork; } const LiItem = ({ idx, network }: LiItemProps) => { const [updateIsOpen, toggleUpdate] = useToggle(false) const [edit, toggleEdit] = useToggle(false); return (
  • {/*
    Enable
    */}
    { network.enabled ? ( network.connected ? ( ) : ) : } {network.name}
    {network.server}:{network.port} {network.tls && TLS}
    {network.nickserv.account}
    Edit
    {edit && (
    1. Channel
      Monitoring since
      Last announce
    2. {network.channels.map(c => (
    3. { network.enabled ? ( c.monitoring ? ( ) : ) : } {c.name}
      {IsEmptyDate(c.monitoring_since)}
      {IsEmptyDate(c.last_announce)}
    4. ))}
    )}
  • ) } export default IrcSettings;