import { At, Key, Block } from "@styled-icons/boxicons-regular"; import { Envelope, HelpCircle, Lock, Trash, Pencil, } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { useHistory } from "react-router-dom"; import { API } from "revolt.js"; import styles from "./Panes.module.scss"; import { Text } from "preact-i18n"; import { useContext, useEffect, useState } from "preact/hooks"; import { Button, CategoryButton, LineDivider, Tip } from "@revoltchat/ui"; import { stopPropagation } from "../../../lib/stopPropagation"; import { useIntermediate } from "../../../context/intermediate/Intermediate"; import { ClientStatus, LogOutContext, StatusContext, useClient, } from "../../../context/revoltjs/RevoltClient"; import Tooltip from "../../../components/common/Tooltip"; import UserIcon from "../../../components/common/user/UserIcon"; export const Account = observer(() => { const { openScreen, writeClipboard } = useIntermediate(); const logOut = useContext(LogOutContext); const status = useContext(StatusContext); const client = useClient(); const [email, setEmail] = useState("..."); const [revealEmail, setRevealEmail] = useState(false); const [profile, setProfile] = useState( undefined, ); const history = useHistory(); function switchPage(to: string) { history.replace(`/settings/${to}`); } useEffect(() => { if (email === "..." && status === ClientStatus.ONLINE) { client.api .get("/auth/account/") .then((account) => setEmail(account.email)); } if (profile === undefined && status === ClientStatus.ONLINE) { client .user!.fetchProfile() .then((profile) => setProfile(profile ?? {})); } }, [client, email, profile, status]); return (
switchPage("profile")} />
switchPage("profile")} />
@{client.user!.username}
{( [ [ "username", client.user!.username, , ], ["email", email, ], ["password", "•••••••••", ], ] as const ).map(([field, value, icon]) => ( {value}{" "} stopPropagation( ev, setRevealEmail(false), ) }> ) : ( <> •••••••••••@••••••.•••{" "} stopPropagation( ev, setRevealEmail(true), ) }> ) ) : ( value ) } account action={} onClick={() => openScreen({ id: "modify_account", field, }) }> ))}

{/**/} Two-factor authentication is currently in-development, see{" "} tracking issue here .
} description={"Set up 2FA on your account."} disabled action={}> Set up Two-factor authentication {/*} description={"View and download your 2FA backup codes."} disabled action="chevron"> View my backup codes */}

} description={ "Disable your account. You won't be able to access it unless you contact support." } action="chevron" onClick={() => client.api .post("/auth/account/disable", undefined, { headers: { "X-MFA-Ticket": "TICKET", }, }) .then(() => logOut(true)) }> } description={ "Your account will be queued for deletion, a confirmation email will be sent." } action="chevron" onClick={() => client.api .post("/auth/account/delete", undefined, { headers: { "X-MFA-Ticket": "TICKET", }, }) .then(() => logOut(true)) }> {" "} switchPage("profile")}>
); });