refactor: update article deletion and retrieval methods to use external ID

This commit is contained in:
2026-04-17 00:12:44 -03:00
parent 873e372bad
commit b9e34e590d
11 changed files with 134 additions and 115 deletions

View File

@@ -1,6 +1,6 @@
'use client';
import { deleteArticle } from '@/lib/feature/article/article.external';
import { deleteArticleByExternalId } from '@/lib/feature/article/article.external';
import {
AlertDialog,
AlertDialogAction,
@@ -13,24 +13,25 @@ import {
AlertDialogTrigger,
} from '@/ui/components/shadcn/alert-dialog';
import { Button } from '@/ui/components/shadcn/button';
import { UUIDv4 } from '@/utils/types/uuid';
import { Trash2Icon } from 'lucide-react';
import { useTransition } from 'react';
import { toast } from 'sonner';
interface DeleteArticleButtonProps {
articleId: string;
articleTitle: string;
externalID: UUIDv4;
title: string;
}
export const DeleteArticleButton = ({
articleId,
articleTitle,
externalID,
title,
}: DeleteArticleButtonProps) => {
const [isPending, startTransition] = useTransition();
const handleDelete = () => {
startTransition(async () => {
const result = await deleteArticle(articleId);
const result = await deleteArticleByExternalId(externalID);
if (!result.ok) {
toast.error('Failed to delete article', {
description: result.error.message,
@@ -39,7 +40,7 @@ export const DeleteArticleButton = ({
return;
}
toast.success('Article deleted', {
description: `"${articleTitle}" has been removed.`,
description: `"${title}" has been removed.`,
position: 'bottom-right',
});
});
@@ -57,7 +58,7 @@ export const DeleteArticleButton = ({
<AlertDialogHeader>
<AlertDialogTitle>Delete article?</AlertDialogTitle>
<AlertDialogDescription>
This will permanently delete &ldquo;{articleTitle}
This will permanently delete &ldquo;{title}
&rdquo;. This action cannot be undone.
</AlertDialogDescription>
</AlertDialogHeader>