feat: citizenship applications
This commit is contained in:
@@ -14,16 +14,17 @@ 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";
|
||||
|
||||
type Draft = { id: string; title: string; slug: string; updatedAt: Date };
|
||||
type Draft = { id: string; type: PageType; title: string; slug: string; updatedAt: Date | null };
|
||||
|
||||
export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
|
||||
const [isDeletingId, setIsDeletingId] = useState("");
|
||||
|
||||
async function deletePage(id: string) {
|
||||
async function deletePage(id: string, type: PageType) {
|
||||
setIsDeletingId(id);
|
||||
try {
|
||||
await deletePageAction(id)
|
||||
await deletePageAction(id, type)
|
||||
} finally {
|
||||
setIsDeletingId("")
|
||||
}
|
||||
@@ -51,7 +52,7 @@ export default function DraftsDialog({ drafts }: { drafts: Draft[]}) {
|
||||
<Link href={`/news/${draft.slug}/edit`}>
|
||||
<Button variant="secondary" size="icon-sm"><PencilIcon /></Button>
|
||||
</Link>
|
||||
<Button disabled={isDeletingId === draft.id} variant="secondary" size="icon-sm" onClick={() => deletePage(draft.id)}>
|
||||
<Button disabled={isDeletingId === draft.id} variant="secondary" size="icon-sm" onClick={() => deletePage(draft.id, draft.type)}>
|
||||
{isDeletingId === draft.id ? <Spinner /> : <XIcon />}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user