import { At, Key, Block } from "@styled-icons/boxicons-regular"; import { Envelope, Lock, Trash, Pencil } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { Link } from "react-router-dom"; import styles from "./Panes.module.scss"; import { Text } from "preact-i18n"; import { useContext, useEffect, useState } from "preact/hooks"; import { AccountDetail, CategoryButton, Column, HiddenValue, Tip, } from "@revoltchat/ui"; import { useIntermediate } from "../../../context/intermediate/Intermediate"; import { modalController } from "../../../context/modals"; import { ClientStatus, LogOutContext, StatusContext, useClient, } from "../../../context/revoltjs/RevoltClient"; export const Account = observer(() => { const { openScreen } = useIntermediate(); const logOut = useContext(LogOutContext); const status = useContext(StatusContext); const client = useClient(); const [email, setEmail] = useState("..."); useEffect(() => { if (email === "..." && status === ClientStatus.ONLINE) { client.api .get("/auth/account/") .then((account) => setEmail(account.email)); } }, [client, email, status]); return (
{( [ ["username", client.user!.username, At], ["email", email, Envelope], ["password", "•••••••••", Key], ] as const ).map(([field, value, Icon]) => ( } description={ field === "email" ? ( ) : ( 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={() => modalController.push({ type: "mfa_flow", state: "known", client, callback: ({ token }) => client.api .post("/auth/account/disable", undefined, { headers: { "X-MFA-Ticket": token, }, }) .then(() => logOut(true)), }) }> } description={ "Your account will be queued for deletion, a confirmation email will be sent." } action="chevron" onClick={() => modalController.push({ type: "mfa_flow", state: "known", client, callback: ({ token }) => client.api .post("/auth/account/delete", undefined, { headers: { "X-MFA-Ticket": token, }, }) .then(() => logOut(true)), }) }> {" "}
); });