import { useAsyncFn } from "react-use"; import { deleteUser } from "@/backend/accounts/user"; import { Button } from "@/components/Button"; import { SolidSettingsCard } from "@/components/layout/SettingsCard"; import { Modal, ModalCard, useModal } from "@/components/overlays/Modal"; import { Heading2, Heading3, Paragraph } from "@/components/utils/Text"; import { useAuthData } from "@/hooks/auth/useAuthData"; import { useBackendUrl } from "@/hooks/auth/useBackendUrl"; import { useAuthStore } from "@/stores/auth"; export function AccountActionsPart() { const url = useBackendUrl(); const account = useAuthStore((s) => s.account); const { logout } = useAuthData(); const deleteModal = useModal("account-delete"); const [deleteResult, deleteExec] = useAsyncFn(async () => { if (!account) return; await deleteUser(url, account); await logout(); deleteModal.hide(); }, [logout, account, url, deleteModal.hide]); if (!account) return null; return (
Actions
Delete account

This action is irreversible. All data will be deleted and nothing can be recovered.

Are you sure? Are you sure you want to delete your account? All your data will be lost!
); }