mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-13 18:59:22 -05:00
feat: add account deletion confirmation route
This commit is contained in:
parent
71f8fc86a4
commit
bd50378234
2 changed files with 60 additions and 0 deletions
|
@ -13,6 +13,7 @@ import { CheckAuth } from "../context/revoltjs/CheckAuth";
|
||||||
import Invite from "./invite/Invite";
|
import Invite from "./invite/Invite";
|
||||||
|
|
||||||
const Login = lazy(() => import("./login/Login"));
|
const Login = lazy(() => import("./login/Login"));
|
||||||
|
const ConfirmDelete = lazy(() => import("./login/ConfirmDelete"));
|
||||||
const RevoltApp = lazy(() => import("./RevoltApp"));
|
const RevoltApp = lazy(() => import("./RevoltApp"));
|
||||||
|
|
||||||
export function App() {
|
export function App() {
|
||||||
|
@ -30,6 +31,9 @@ export function App() {
|
||||||
<Route path="/login/reset/:token">
|
<Route path="/login/reset/:token">
|
||||||
<Login />
|
<Login />
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route path="/delete/:token">
|
||||||
|
<ConfirmDelete />
|
||||||
|
</Route>
|
||||||
<Route path="/invite/:code">
|
<Route path="/invite/:code">
|
||||||
<CheckAuth blockRender>
|
<CheckAuth blockRender>
|
||||||
<FakeClient>
|
<FakeClient>
|
||||||
|
|
56
src/pages/login/ConfirmDelete.tsx
Normal file
56
src/pages/login/ConfirmDelete.tsx
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
import { Check } from "@styled-icons/boxicons-regular";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
import { useEffect, useState } from "preact/hooks";
|
||||||
|
|
||||||
|
import { Modal, Preloader } from "@revoltchat/ui";
|
||||||
|
|
||||||
|
import { useApplicationState } from "../../mobx/State";
|
||||||
|
|
||||||
|
const Centre = styled.div`
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default function ConfirmDelete() {
|
||||||
|
const state = useApplicationState();
|
||||||
|
const [deleted, setDeleted] = useState(true);
|
||||||
|
const { token } = useParams<{ token: string }>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
state.config
|
||||||
|
.createClient()
|
||||||
|
.api.put("/auth/account/delete", { token })
|
||||||
|
.then(() => setDeleted(true));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
title={deleted ? "Confirmed deletion." : "Please wait..."}
|
||||||
|
description={
|
||||||
|
deleted ? (
|
||||||
|
<>
|
||||||
|
Your account will be deleted in 7 days.
|
||||||
|
<br />
|
||||||
|
You may contact{" "}
|
||||||
|
<a href="mailto:contact@revolt.chat">
|
||||||
|
Revolt support
|
||||||
|
</a>{" "}
|
||||||
|
to cancel the request if you wish.
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
"Contacting the server."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
nonDismissable>
|
||||||
|
{deleted ? (
|
||||||
|
<Centre>
|
||||||
|
<Check size={48} />
|
||||||
|
</Centre>
|
||||||
|
) : (
|
||||||
|
<Preloader type="ring" />
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in a new issue