Initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
"use client";
|
||||
import { useTransition } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Trash2 } from "lucide-react";
|
||||
import { emptyTrash } from "@/app/actions/trash";
|
||||
|
||||
export function EmptyTrashButton({ count }: { count: number }) {
|
||||
const [pending, start] = useTransition();
|
||||
const router = useRouter();
|
||||
if (count === 0) return null;
|
||||
const onClick = () => {
|
||||
if (!confirm(`Permanently delete ${count} image${count === 1 ? "" : "s"}? Cannot be undone.`)) return;
|
||||
start(async () => {
|
||||
await emptyTrash();
|
||||
router.refresh();
|
||||
});
|
||||
};
|
||||
return (
|
||||
<button
|
||||
onClick={onClick}
|
||||
disabled={pending}
|
||||
className="flex items-center gap-1.5 text-sm px-3 py-1.5 rounded-lg bg-[var(--color-coral)]/15 text-[var(--color-coral)] border border-[var(--color-coral)]/40 hover:bg-[var(--color-coral)]/25 disabled:opacity-50"
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
{pending ? "Emptying…" : "Empty trash"}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user