import { At, Key, Block } from "@styled-icons/boxicons-regular"; import { Envelope, HelpCircle, Lock, Trash, } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { useHistory } from "react-router-dom"; import { Profile } from "revolt-api/types/Users"; import styles from "./Panes.module.scss"; import { Text } from "preact-i18n"; import { useContext, useEffect, useState } from "preact/hooks"; import { stopPropagation } from "../../../lib/stopPropagation"; import { useIntermediate } from "../../../context/intermediate/Intermediate"; import { ClientStatus, StatusContext, useClient, } from "../../../context/revoltjs/RevoltClient"; import Tooltip from "../../../components/common/Tooltip"; import UserIcon from "../../../components/common/user/UserIcon"; import Button from "../../../components/ui/Button"; import Tip from "../../../components/ui/Tip"; import CategoryButton from "../../../components/ui/fluent/CategoryButton"; export const Account = observer(() => { const { openScreen, writeClipboard } = useIntermediate(); 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 .req("GET", "/auth/user") .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")} />
{( [ [ "username", client.user!.username, , ], ["email", email, ], ["password", "•••••••••", ], ] as const ).map(([field, value, icon]) => ( {value}{" "} stopPropagation( ev, setRevealEmail(false), ) }> ) : ( <> •••••••••••@{value.split("@").pop()}{" "} stopPropagation( ev, setRevealEmail(true), ) }> ) ) : ( value ) } account action="chevron" onClick={() => openScreen({ id: "modify_account", field, }) }> ))}

{/**/} Two-factor authentication is currently work-in-progress, see{" "} {` `} tracking issue here .
} description={"Set up 2FA Authentication on your account."} disabled action="chevron"> Set up Two-factor authentication

} description={ "Disable your account. You won't be able to access it unless you log back in." } disabled action={}> } description={ "Delete your account, including all of your data." } hover action="external"> {" "} switchPage("profile")}>
); });