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

interface CommissionerAutodraftDialogProps {
  open: boolean;
  onOpenChange: (open: boolean) => void;
  teamId: string | null;
  teamName: string | undefined;
  seasonId: string;
  isEnabled: boolean;
  mode: "next_pick" | "while_on";
  queueOnly: boolean;
  onUpdate: (isEnabled: boolean, mode: "next_pick" | "while_on", queueOnly: boolean) => void;
}

export function CommissionerAutodraftDialog({
  open,
  onOpenChange,
  teamId,
  teamName,
  seasonId,
  isEnabled,
  mode,
  queueOnly,
  onUpdate,
}: CommissionerAutodraftDialogProps) {
  return (
    <Dialog
      open={open}
      onOpenChange={(isOpen) => {
        onOpenChange(isOpen);
      }}
    >
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Set Autodraft</DialogTitle>
          <DialogDescription>
            {teamId
              ? `Change autodraft for ${teamName ?? "this team"}`
              : "Set a team's autodraft settings"}
          </DialogDescription>
        </DialogHeader>
        {teamId && (
          <AutodraftSettings
            seasonId={seasonId}
            teamId={teamId}
            isEnabled={isEnabled}
            mode={mode}
            queueOnly={queueOnly}
            isMyTurn={false}
            onUpdate={onUpdate}
          />
        )}
      </DialogContent>
    </Dialog>
  );
}
