"use client"
import React, { useState, useEffect } from "react"
import { createPortal } from "react-dom"
import { cn } from "@/lib/utils"
interface CustomAlertDialogProps {
title: string
description: string
cancelText?: string
confirmText?: string
onCancel?: () => void
onConfirm?: () => void
variant?: "default" | "destructive"
}
export function CustomAlertDialogTrigger({
children,
dialogProps,
}: {
children: React.ReactNode
dialogProps: CustomAlertDialogProps
}) {
const [isOpen, setIsOpen] = useState(false)
const openDialog = () => setIsOpen(true)
const closeDialog = () => setIsOpen(false)
const handleCancel = () => {
dialogProps.onCancel?.()
closeDialog()
}
const handleConfirm = () => {
dialogProps.onConfirm?.()
closeDialog()
}
return (
<>
{React.cloneElement(children as React.ReactElement, { onClick: openDialog })}
{isOpen && (
{description}