"use client"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { deletePageAction } from "@/lib/pages/actions"; import { PencilIcon, XIcon } from "lucide-react"; import Link from "next/link"; import { useState } from "react"; import { Spinner } from "@/components/ui/spinner"; import { PageType } from "@/lib/pages/types"; import { useAction } from "@/hooks/useAction"; type Draft = { id: string; type: PageType; title: string; slug: string; updatedAt: Date | null }; function DraftItem({ draft, onDeleted }: { draft: Draft; onDeleted: (id: string) => void }) { const { run, isPending } = useAction(deletePageAction, { successMessage: "Draft deleted", onSuccess: () => onDeleted(draft.id), }); return (

{draft.title}

); } export default function DraftsDialog({ drafts }: { drafts: Draft[]}) { const [items, setItems] = useState(drafts); function handleDeleted(id: string) { setItems((prev) => prev.filter((d) => d.id !== id)); } return ( Drafts Here are drafts of your pages {items.length > 0 ? (
{items.map((draft) => ( ))}
) : (

There are no drafts yet...

)}
) }