"use client";
import { useState, useTransition } from "react";
import { useRouter } from "next/navigation";
import { Trash2Icon } from "lucide-react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { PurgeDialog } from "@/components/archive/purge-dialog";
import { emptyArchiveAction } from "@/server/actions";
/** Hidden entirely when the bin is empty: there is nothing to empty. */
export function EmptyArchiveButton({ total }: { total: number }) {
const router = useRouter();
const [open, setOpen] = useState(false);
const [pending, startTransition] = useTransition();
const empty = () =>
startTransition(async () => {
try {
const result = await emptyArchiveAction();
toast.success(`${result.total} deleted for good`);
setOpen(false);
router.refresh();
} catch (error) {
toast.error(error instanceof Error ? error.message : "Could not empty the archive.");
}
});
return (
<>
>
);
}