"use client";

import ProfilePictureCropModal from "./ProfilePictureCropModal";

/**
 * The organization logo's crop dialog.
 *
 * Kept apart from the volunteer one: this cancels through its own
 * `handleCropCancel`, which also clears the single `fileInputRef` rather than
 * sweeping every file input on the page.
 */
export default function OrganizerLogoCropGate({
  showCropModal,
  imageToCrop,
  onCropComplete,
  onCropCancel,
}: {
  showCropModal: boolean;
  imageToCrop: string;
  onCropComplete: (croppedImage: File) => Promise<void> | void;
  onCropCancel: () => void;
}) {
  return (
    <>
      {/* Render crop modal outside of the main component flow */}
      {showCropModal && imageToCrop && (
        <ProfilePictureCropModal
          imageSrc={imageToCrop}
          onCropComplete={onCropComplete}
          onCancel={onCropCancel}
        />
      )}
    </>
  );
}
