feat(ui): confirm destructive admin actions
Some checks failed
Frontend CI/CD / build (push) Has been cancelled
Frontend CI/CD / deploy (push) Has been cancelled

This commit is contained in:
2026-06-14 09:10:32 +03:30
parent 4e24b96068
commit fc94ceb9f5
10 changed files with 171 additions and 41 deletions

View File

@@ -3,6 +3,7 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { AlertTriangle, ArrowLeft, ArrowRight, FolderUp, ImageUp, Loader2, Save, Send, Trash2 } from "lucide-react";
import { useRouter } from "next/navigation";
import ConfirmAction from "@/components/ConfirmAction";
import Markdown from "@/components/Markdown";
import MarkdownEditor, { type MarkdownDirectionMode } from "@/components/MarkdownEditor";
import { useAuth } from "@/contexts/AuthContext";
@@ -384,10 +385,18 @@ export default function AdminBlogEditor({ postId }: Props) {
</div>
<div className="flex flex-wrap justify-end gap-2">
{post?.featured_image || post?.absolute_featured_image_url ? (
<Button variant="outline" onClick={deleteFeaturedImage} disabled={uploadingFeatured}>
<ConfirmAction
title="حذف تصویر شاخص"
description="آیا از حذف تصویر شاخص این نوشته مطمئن هستید؟"
onConfirm={deleteFeaturedImage}
disabled={uploadingFeatured}
trigger={
<Button variant="outline" disabled={uploadingFeatured}>
<Trash2 className="ml-2 h-4 w-4" />
حذف تصویر
</Button>
</Button>
}
/>
) : null}
<Button variant="secondary" onClick={() => featuredInputRef.current?.click()} disabled={uploadingFeatured || saving}>
{uploadingFeatured ? <Loader2 className="ml-2 h-4 w-4 animate-spin" /> : <ImageUp className="ml-2 h-4 w-4" />}