import { ArrowBack } from "@styled-icons/boxicons-regular"; import { Redirect, useHistory, useParams } from "react-router-dom"; import { API } from "revolt.js"; import styles from "./Invite.module.scss"; import { Text } from "preact-i18n"; import { useEffect, useState } from "preact/hooks"; import { Button, Category, Error, Preloader } from "@revoltchat/ui"; import { TextReact } from "../../lib/i18n"; import { useApplicationState } from "../../mobx/State"; import ServerIcon from "../../components/common/ServerIcon"; import UserIcon from "../../components/common/user/UserIcon"; import { useClient, useSession, } from "../../controllers/client/ClientController"; import RequiresOnline from "../../controllers/client/jsx/RequiresOnline"; import { takeError } from "../../controllers/client/jsx/error"; export default function Invite() { const history = useHistory(); const session = useSession(); const client = useClient(); const layout = useApplicationState().layout; const { code } = useParams<{ code: string }>(); const [processing, setProcessing] = useState(false); const [error, setError] = useState(undefined); const [invite, setInvite] = useState( undefined, ); useEffect(() => { if (typeof invite === "undefined") { client .fetchInvite(code) .then((data) => setInvite(data)) .catch((err) => setError(takeError(err))); } }, [code, invite]); if (code === undefined) return ; if (typeof invite === "undefined") { return (
{error ? (

) : ( )}
); } if (invite.type === "Group") return

unimplemented

; return (
history.push(layout.getLastPath())} />
{!processing && (
)}
{processing ? ( ) : ( <>

{invite.server_name}

#{invite.channel_name} •{" "}

{" "} {invite.user_name} ), }} />

)}
); }