Tech TutorBangla Web Documentation
Portfolio
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • TanStack Documentation42টি অধ্যায়
প্রযুক্তি নির্বাচন
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Project Overview
  • Architecture
  • Folder Structure
  • Setup Next.js
  • Axios Setup
  • API Client
  • API Types
  • Query Install
  • Query Provider
  • Query Keys
  • Data Fetching
  • States
  • Devtools
  • Create Mutation
  • Update Mutation
  • Delete Mutation
  • Cache Invalidation
  • Optimistic Update
  • Pagination
  • Search
  • Filtering
  • Sorting
  • TanStack Table
  • Table Explore
  • Table Columns
  • Table Actions
  • React Hook Form
  • Zod Validation
  • Create Form
  • Edit Form
  • Dialog Modal
  • Delete Confirmation
  • Complete CRUD Flow
  • Full Integration
  • Error Handling
  • Loading States
  • Reusable Components
  • Production
  • Complete Project
  • Common Mistakes
  • Best Practices
  • Interview Q&A
  1. Docs
  2. TanStack
  3. Delete Confirmation Dialog
TanStackIntermediate

Delete Confirmation Dialog

AlertDialog দিয়ে destructive action confirm — বাংলায়।

6টি অংশবাংলা ভাষায়
delete-alert-dialog.tsxtsx
tsx
"use client";

import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
} from "@/components/ui/alert-dialog";

interface DeleteDialogProps {
  product: Product | null;
  open: boolean;
  onOpenChange: (open: boolean) => void;
  onConfirm: () => void;
  isDeleting?: boolean;
}

export function DeleteDialog({
  product,
  open,
  onOpenChange,
  onConfirm,
  isDeleting,
}: DeleteDialogProps) {
  return (
    <AlertDialog open={open} onOpenChange={onOpenChange}>
      <AlertDialogContent>
        <AlertDialogHeader>
          <AlertDialogTitle>নিশ্চিত?</AlertDialogTitle>
          <AlertDialogDescription>
            আপনি কি নিশ্চিত যে <b>{product?.name}</b> মুছে ফেলতে চান?
            এই কাজটি পূর্বাবস্থায় ফেরানো যাবে না।
          </AlertDialogDescription>
        </AlertDialogHeader>
        <AlertDialogFooter>
          <AlertDialogCancel disabled={isDeleting}>বাতিল</AlertDialogCancel>
          <AlertDialogAction
            disabled={isDeleting}
            onClick={(e) => {
              e.preventDefault();
              onConfirm();
            }}
          >
            {isDeleting ? "মুছে ফেলা হচ্ছে…" : "হ্যাঁ, মুছে ফেলুন"}
          </AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
}

কেন e.preventDefault

AlertDialogAction ডিফল্ট dialog বন্ধ করে দেয়। আমরা চাই disabling state-এর পরে delete শেষ হয়ে onOpenChange(false) ডাকা হোক — তাই onClick-এ preventDefault করে সেটা নিজে manage করছি। (যদি চাই তাৎক্ষণিক close, তবে ছাড়া concern নয়।.)

dashboard-এ wiring

Page-এtsx
tsx
const [deletingProduct, setDeletingProduct] = useState<Product | null>(null);
const deleteProduct = useDeleteProduct();

<DeleteDialog
  product={deletingProduct}
  open={deletingProduct !== null}
  onOpenChange={(open) => {
    if (!open && !deleteProduct.isPending) setDeletingProduct(null);
  }}
  isDeleting={deleteProduct.isPending}
  onConfirm={() => {
    deleteProduct.mutate(deletingProduct!.id, {
      onSuccess: () => setDeletingProduct(null),
    });
  }}
/>
destructive pattern

destructive action-এ সুস্পষ্ট শব্দ: 'হ্যাঁ, মুছে ফেলুন' — চোখে চলে। AlertDialogCancel সর্বদা keep করুন — user-কে ফাঁস বিহীন বিকল্প দিন।

শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।
আগেরDialog Modal — Create ও EditপরেরComplete CRUD — এক জায়গায়
এই পেজে
Tech Tutor

বাংলায় ওয়েব ডেভেলপমেন্ট ডকুমেন্টেশন শিখুন — ধাপে ধাপে।

Homeসব ডকুমেন্টেশনQuick Startআমার নোটস

© 2026 Tech Tutor. বাংলায় শিখুন, বাংলায় গড়ুন।

mdanamolhasan1998@gmail.com