satupeta-main/shared/components/ds/success-dialog.tsx
2026-02-23 12:21:05 +07:00

63 lines
1.5 KiB
TypeScript
Executable File

// components/success-dialog.tsx
"use client";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/shared/components/ui/alert-dialog";
import { ReactNode } from "react";
type SuccessDialogProps = {
open: boolean;
onOpenChange: (open: boolean) => void;
title?: string;
description?: string;
confirmText?: string;
cancelText?: string;
onConfirm?: () => void;
onCancel?: () => void;
children?: ReactNode;
};
export function SuccessDialog({
open,
onOpenChange,
title = "Success!",
description = "Operation completed successfully.",
confirmText = "OK",
cancelText,
onConfirm,
onCancel,
children,
}: Readonly<SuccessDialogProps>) {
return (
<AlertDialog open={open} onOpenChange={onOpenChange}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>{title}</AlertDialogTitle>
<AlertDialogDescription>
{description}
{children}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
{cancelText && (
<AlertDialogCancel onClick={onCancel}>
{cancelText}
</AlertDialogCancel>
)}
<AlertDialogAction onClick={onConfirm}>
{confirmText}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}