import React from "react";

export default function AuthActions({
  isCodeStep = false,
  isSubmitting = false,
  canSubmitStep1 = true,

  // متن‌ها
  primaryText,
  secondaryText,

  // هندلرها
  onPrimary,     // ✅ جدید: کلیک دکمه اصلی
  onSecondary,
  showSecondary = true,
  onSecondary2,
  showSecondary2 = true,
  onSecondary3,
  showSecondary3 = true,
}) {
  const primaryLabel = primaryText || (isCodeStep ? "تایید کد" : "ورود/ثبت‌نام");
  const secondaryLabel = secondaryText || (isCodeStep ? "تغییر شماره" : "");
  const secondaryLabel2 = "ورود با شماره";
  const secondaryLabel3 = "ورود با نام کاربری";

  const disablePrimary = isSubmitting || (!isCodeStep && !canSubmitStep1);

  return (
    <div className="w-full grid gap-4 h-fit mt-6">
      {/* ✅ تغییر: دکمه اصلی به submit برای صفحه ورود */}
      <button
  className="bg-[#001F3F] text-white px-5 py-2 rounded-md disabled:opacity-50 disabled:cursor-not-allowed"
  type="button"
  onClick={onPrimary}
  disabled={disablePrimary}
>
  {isSubmitting ? "در حال انجام..." : primaryLabel}
</button>


      {showSecondary && !!secondaryLabel && !!onSecondary && (
        <button
          type="button"
          onClick={onSecondary}
          className="bg-[#001F3F61] hover:bg-[#001F3F] text-white px-5 py-2 rounded-md w-full font-medium text-sm disabled:opacity-50 disabled:cursor-not-allowed"
          disabled={isSubmitting}
        >
          {secondaryLabel}
        </button>
      )}
      {showSecondary2 && !!secondaryLabel2 && !!onSecondary2 && (
        <button
          type="button"
          onClick={onSecondary2}
          className="bg-[#001F3F61] hover:bg-[#001F3F] text-white px-5 py-2 rounded-md w-full font-medium text-sm disabled:opacity-50 disabled:cursor-not-allowed"
          disabled={isSubmitting}
        >
          {secondaryLabel2}
        </button>
      )}
      {showSecondary3 && !!secondaryLabel3 && !!onSecondary3 && (
        <button
          type="button"
          onClick={onSecondary3}
          className="bg-[#001F3F61] hover:bg-[#001F3F] text-white px-5 py-2 rounded-md w-full font-medium text-sm disabled:opacity-50 disabled:cursor-not-allowed"
          disabled={isSubmitting}
        >
          {secondaryLabel3}
        </button>
      )}
    </div>
  );
}
