import React, { useState } from "react"; import { toast } from "react-hot-toast"; import TextInput from "@/components/TextInput"; import CenteredForm from "@/layouts/CenteredForm"; import { signOut, useSession } from "next-auth/react"; import Link from "next/link"; import Button from "@/components/ui/Button"; const keycloakEnabled = process.env.NEXT_PUBLIC_KEYCLOAK_ENABLED === "true"; const authentikEnabled = process.env.NEXT_PUBLIC_AUTHENTIK_ENABLED === "true"; export default function Delete() { const [password, setPassword] = useState(""); const [comment, setComment] = useState(); const [feedback, setFeedback] = useState(); const [submitLoader, setSubmitLoader] = useState(false); const { data } = useSession(); const submit = async () => { const body = { password, cancellation_details: { comment, feedback, }, }; if (!keycloakEnabled && !authentikEnabled && password == "") { return toast.error("Please fill the required fields."); } setSubmitLoader(true); const load = toast.loading("Deleting everything, please wait..."); const response = await fetch(`/api/v1/users/${data?.user.id}`, { method: "DELETE", headers: { "Content-Type": "application/json", }, body: JSON.stringify(body), }); const message = (await response.json()).response; toast.dismiss(load); if (response.ok) { signOut(); } else toast.error(message); setSubmitLoader(false); }; return (

Delete Account

This will permanently delete all the Links, Collections, Tags, and archived data you own. It will also log you out {process.env.NEXT_PUBLIC_STRIPE ? " and cancel your subscription" : undefined} . This action is irreversible!

{process.env.NEXT_PUBLIC_KEYCLOAK_ENABLED !== "true" ? (

Confirm Your Password

setPassword(e.target.value)} placeholder="••••••••••••••" className="bg-base-100" type="password" />
) : undefined} {process.env.NEXT_PUBLIC_STRIPE ? (
Optional{" "} (but it really helps us improve!)

More information (the more details, the more helpful it'd be)