import type { ReactNode } from "react";

import {
  Dialog,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog";

import { Button } from "@/components/ui/button";

export interface DeleteBookingDialogProps {
  bookingReference: string;
  onConfirm?: () => void;
  children: ReactNode;
}

export default function DeleteBookingDialog({
  bookingReference,
  onConfirm,
  children,
}: DeleteBookingDialogProps) {
  return (
    <Dialog>
      <DialogTrigger asChild>{children}</DialogTrigger>

      <DialogContent className="sm:max-w-md rounded-3xl">
        <DialogHeader>
          <DialogTitle className="text-xl font-bold">
            Cancel booking?
          </DialogTitle>

          <DialogDescription>
            This will permanently cancel booking{" "}
            <span className="font-semibold text-slate-900">
              {bookingReference}
            </span>
            . This action cannot be undone.
          </DialogDescription>
        </DialogHeader>

        <DialogFooter className="mt-2">
          <DialogClose asChild>
            <Button variant="outline">Keep booking</Button>
          </DialogClose>

          <DialogClose asChild>
            <Button
              onClick={onConfirm}
              className="bg-red-600 text-white hover:bg-red-700"
            >
              Cancel booking
            </Button>
          </DialogClose>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  );
}
