diff --git a/src/components/README.md b/src/components/README.md new file mode 100644 index 00000000..2aa9f1cc --- /dev/null +++ b/src/components/README.md @@ -0,0 +1,14 @@ +The following folders should not be added to or modified: + +- `common` +- `markdown` +- `native` +- `ui` + +The following are part-legacy, will remain in place and will be rewritten to some degree still: + +- `navigation` + +The following are mostly good to go: + +- `settings` diff --git a/src/components/settings/account/AccountManagement.tsx b/src/components/settings/account/AccountManagement.tsx new file mode 100644 index 00000000..05d82e97 --- /dev/null +++ b/src/components/settings/account/AccountManagement.tsx @@ -0,0 +1,64 @@ +import { Block } from "@styled-icons/boxicons-regular"; +import { Trash } from "@styled-icons/boxicons-solid"; + +import { Text } from "preact-i18n"; +import { useContext } from "preact/hooks"; + +import { CategoryButton } from "@revoltchat/ui"; + +import { modalController } from "../../../context/modals"; +import { + LogOutContext, + useClient, +} from "../../../context/revoltjs/RevoltClient"; + +export default function AccountManagement() { + const logOut = useContext(LogOutContext); + const client = useClient(); + + const callback = (route: "disable" | "delete") => () => + modalController.push({ + type: "mfa_flow", + state: "known", + client, + callback: ({ token }) => + client.api + .post(`/auth/account/${route}`, undefined, { + headers: { + "X-MFA-Ticket": token, + }, + }) + .then(() => logOut(true)), + }); + + return ( + <> +