diff --git a/.gitignore b/.gitignore index 233f6745..956667df 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ dist .env* !.env.example .vercel + +.idea \ No newline at end of file diff --git a/packages/client/src/index.tsx b/packages/client/src/index.tsx index 10141ad8..4e71df97 100644 --- a/packages/client/src/index.tsx +++ b/packages/client/src/index.tsx @@ -1,7 +1,7 @@ /** * Configure contexts and render App */ -import { JSX, Show, createEffect, createSignal, on, onMount } from "solid-js"; +import { JSX, Show, createEffect, createSignal, on, onMount, lazy } from "solid-js"; import { createStore } from "solid-js/store"; import { render } from "solid-js/web"; @@ -44,6 +44,7 @@ import { HomePage } from "./interface/Home"; import { ServerHome } from "./interface/ServerHome"; import { ChannelPage } from "./interface/channels/ChannelPage"; import "./sentry"; +import { ConfirmDelete } from "./interface/ConfirmDelete"; attachDevtoolsOverlay(); @@ -119,6 +120,7 @@ render( () => ( + diff --git a/packages/client/src/interface/ConfirmDelete.tsx b/packages/client/src/interface/ConfirmDelete.tsx new file mode 100644 index 00000000..21342e00 --- /dev/null +++ b/packages/client/src/interface/ConfirmDelete.tsx @@ -0,0 +1,81 @@ +import { getController } from "@revolt/common"; +import { createEffect, createMemo, createResource, createSignal, onMount, Show, Suspense } from "solid-js"; +import { useParams } from "@solidjs/router"; +import { Modal, Preloader } from "@revolt/ui"; +import { styled } from "styled-system/jsx"; +import { BiRegularCheck } from "solid-icons/bi"; +import { useTranslation } from "@revolt/i18n"; + +const Centre = styled('div', { + base: { + display: 'flex', + justifyContent: 'center' + } +}); + +const i18nScope = 'app.settings.pages.account.delete'; + +export function ConfirmDelete() { + const t = useTranslation(); + const params = useParams<{ token: string }>(); + const clientController = getController("client"); + const [deleted] = createResource( async () => { + try { + await clientController.api.put("/auth/account/delete", { token: params.token }); + return true; + } catch (e) { + /* + createResource cannot handle thrown errors without ErrorBoundary, + so we wrangle states manually + + null - error + true - deleted + false - initial + */ + return null; + } + }, { + initialValue: false + }) + + const title = createMemo(() => { + if (deleted() === null) return t(`${i18nScope}.error.title`); + + return deleted() ? t(`${i18nScope}.success.title`) : t(`${i18nScope}.loading.title`); + }); + + const description = createMemo(() => { + if (deleted() === null) return t(`${i18nScope}.error.description`); + + if (deleted()) return ( + <> + {t(`${i18nScope}.success.description.header`)} +
+ {t(`${i18nScope}.success.description.paragraph_first`)}{" "} + + {t(`${i18nScope}.success.description.support`)} + {" "} + {t(`${i18nScope}.success.description.paragraph_second`)} + + ) + + return t(`${i18nScope}.loading.description`) + }) + + return ( + + }> + + + + + + + + ) +} \ No newline at end of file