import { cn } from "@/lib/utils"; import { ComponentProps, MouseEventHandler, useEffect, useState } from "react"; import { Button } from "../ui/button"; interface ButtonWithConfirmProps extends Omit, "children"> { readonly text: string; readonly confirmText: string; readonly onClick: MouseEventHandler; } export default function ButtonWithConfirm({ text, confirmText, onClick, ...restProps }: ButtonWithConfirmProps) { const [toConfirm, setToConfirm] = useState(false); useEffect(() => { if (!toConfirm) { return; } const timeout = setTimeout(() => { setToConfirm(false); }, 3000); return () => { clearTimeout(timeout); }; }, [toConfirm]); return ( ); }