"use client" import { useState } from "react" import { useRouter } from "next/navigation" import { useMutation } from "@tanstack/react-query" import { useUnsubscribeAll } from "@/lib/queries/use-subscription-mutations" import { useDeleteAllFolders } from "@/lib/queries/use-folder-mutations" import { useDeleteAllCustomFeeds } from "@/lib/queries/use-custom-feed-mutations" import { notify } from "@/lib/notify" export function DangerZoneSettings() { const router = useRouter() const unsubscribeAll = useUnsubscribeAll() const deleteAllFolders = useDeleteAllFolders() const deleteAllCustomFeeds = useDeleteAllCustomFeeds() const [showDeleteSubsConfirm, setShowDeleteSubsConfirm] = useState(false) const [showDeleteFoldersConfirm, setShowDeleteFoldersConfirm] = useState(false) const [showDeleteCustomFeedsConfirm, setShowDeleteCustomFeedsConfirm] = useState(false) const [showDeleteAccountConfirm, setShowDeleteAccountConfirm] = useState(false) const [deleteConfirmText, setDeleteConfirmText] = useState("") const deleteAccount = useMutation({ mutationFn: async () => { const response = await fetch("/api/account", { method: "DELETE" }) if (!response.ok) throw new Error("failed to delete account") }, onSuccess: () => { router.push("/sign-in") }, onError: (error: Error) => { notify("failed to delete account: " + error.message) }, }) return (

these actions are irreversible. proceed with caution.

remove all subscriptions

unsubscribe from every feed. entries will remain but no new ones will be fetched.

{showDeleteSubsConfirm ? (
are you sure?
) : ( )}

delete all folders

remove all folders. feeds will be ungrouped but not unsubscribed.

{showDeleteFoldersConfirm ? (
are you sure?
) : ( )}

delete all custom feeds

remove all custom feeds (saved searches).

{showDeleteCustomFeedsConfirm ? (
are you sure?
) : ( )}

delete account

permanently delete your account and all associated data. this cannot be undone.

{showDeleteAccountConfirm ? (
{/* eslint-disable-next-line asa-lowercase/lowercase-strings */}

type DELETE to confirm account deletion.

setDeleteConfirmText(event.target.value)} placeholder="type DELETE" // eslint-disable-line asa-lowercase/lowercase-strings className="border border-border bg-background-primary px-3 py-2 text-text-primary outline-none placeholder:text-text-dim focus:border-status-error" autoFocus />
) : ( )}
) }