import { DataStripeAccountStatus } from "@komi-app/sales-sdk";
import { useMemo } from "react";

/**
 * Determines if the Stripe connected account status should hide the paid digital module.
 *
 * @param {DataStripeAccountStatus | undefined} stripeAccountStatusData - The Stripe account status data.
 * @returns {boolean} - Returns `true` if the paid digital module should be hidden, otherwise `false`.
 */
export function useIsConnectedAccountDisabled(
  stripeAccountStatusData?: DataStripeAccountStatus | null,
): boolean {
  return useMemo(() => {
    if (!stripeAccountStatusData) return true;
    const { isEmailConnected, isPaymentEnabled } = stripeAccountStatusData;
    return !isEmailConnected || !isPaymentEnabled;
  }, [stripeAccountStatusData]);
}
