"use client"

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

interface AbandonCreationDialogProps {
  open: boolean;
  onOpenChange: (open: boolean) => void;
  onCancel: () => void;
  onRegenerate: () => void;
  actionType?: 'exit' | 'regenerate';
}

const AbandonCreationDialog = ({
  open,
  onOpenChange,
  onCancel,
  onRegenerate,
  actionType = 'regenerate',
}: AbandonCreationDialogProps) => {
  const router = useRouter();

  const handleConfirm = () => {
    onRegenerate()
  }
  return (
    <AlertDialog open={open} onOpenChange={onOpenChange}>
      <AlertDialogContent>
        <AlertDialogHeader>
          <AlertDialogTitle>Discard Generation</AlertDialogTitle>
        </AlertDialogHeader>
        <AlertDialogDescription>
          If you choose to exit or regenerate, the current images will be lost and one generation attempt will be used.
        </AlertDialogDescription>
        <AlertDialogFooter>
          <AlertDialogCancel onClick={onCancel}>cancel</AlertDialogCancel>
          <AlertDialogAction onClick={handleConfirm}>
            {actionType === 'exit' ? 'Discard' : 'Regenerate'}
          </AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
};

export default AbandonCreationDialog;
