import { Button } from "~/components/ui/button";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "~/components/ui/dialog";

interface RollbackConfirmDialogProps {
  open: boolean;
  onOpenChange: (open: boolean) => void;
  pickNumber: number | null;
  picksCount: number;
  isRollingBack: boolean;
  onConfirm: () => void;
}

export function RollbackConfirmDialog({
  open,
  onOpenChange,
  pickNumber,
  picksCount,
  isRollingBack,
  onConfirm,
}: RollbackConfirmDialogProps) {
  return (
    <Dialog open={open} onOpenChange={onOpenChange}>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Roll Back Draft</DialogTitle>
          <DialogDescription>
            {pickNumber !== null &&
              `This will erase ${picksCount} pick${picksCount === 1 ? "" : "s"} (pick #${pickNumber} through the most recent) and return the draft to pick #${pickNumber}. This cannot be undone.`}
          </DialogDescription>
        </DialogHeader>
        <DialogFooter>
          <Button variant="outline" onClick={() => onOpenChange(false)}>
            Cancel
          </Button>
          <Button variant="destructive" onClick={onConfirm} disabled={isRollingBack}>
            {isRollingBack ? "Rolling Back..." : "Roll Back"}
          </Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  );
}
