import { useTranslation } from "react-i18next";
import { RedactMode } from "@app/hooks/tools/redact/useRedactParameters";
import ButtonSelector from "@app/components/shared/ButtonSelector";

interface RedactModeSelectorProps {
  mode: RedactMode;
  onModeChange: (mode: RedactMode) => void;
  disabled?: boolean;
  hasAnyFiles?: boolean;
}

export default function RedactModeSelector({
  mode,
  onModeChange,
  disabled,
  hasAnyFiles = false,
}: RedactModeSelectorProps) {
  const { t } = useTranslation();

  return (
    <ButtonSelector
      label={t("redact.modeSelector.mode", "Mode")}
      value={mode}
      onChange={onModeChange}
      options={[
        {
          value: "automatic" as const,
          label: t("redact.modeSelector.automatic", "Automatic"),
          disabled: !hasAnyFiles, // Allow switching to automatic whenever files exist; selection can happen after
          tooltip: !hasAnyFiles
            ? t(
                "redact.modeSelector.automaticDisabledTooltip",
                "Upload files to use automatic redaction",
              )
            : undefined,
        },
        {
          value: "manual" as const,
          label: t("redact.modeSelector.manual", "Manual"),
          disabled: !hasAnyFiles, // Manual mode works if any files exist in workbench
        },
      ]}
      disabled={disabled}
    />
  );
}
