import {
  Dialog,
  DialogContent,
  DialogHeader,
  DialogTitle,
} from "@/shared/common/ui/dialog";
import { AssignUserForm } from "../forms/AssignUserForm";

interface AssignUserDialogProps {
  isOpen: boolean;
  onClose: () => void;
  departmentId: string;
  departmentName: string;
  unitId: string;
}

export function AddAssignUserDialog({
  isOpen,
  onClose,
  departmentId,
  departmentName,
  unitId,
}: AssignUserDialogProps) {
  const handleSuccess = () => {
    onClose();
  };

  return (
    <Dialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
      <DialogContent className="sm:max-w-[600px] max-h-[80vh] overflow-hidden flex flex-col">
        <DialogHeader>
          <DialogTitle>Assign User to {departmentName}</DialogTitle>
        </DialogHeader>
        <div className="mt-4 overflow-y-auto flex-1">
          <AssignUserForm
            positionId={departmentId}
            unitId={unitId}
            positionName={departmentName}
            onSuccess={handleSuccess}
            onCancel={onClose}
          />
        </div>
      </DialogContent>
    </Dialog>
  );
}
