import { useApi } from './api.mjs';
import { useSubscription } from './subscription.mjs';

/**
 * Returns the current authenticated `Customer`.
 *
 * The value is `undefined` if the customer isn't authenticated.
 */
function useAuthenticatedAccountCustomer() {
  const account = useApi().authenticatedAccount;
  return useSubscription(account.customer);
}

/**
 * Provides information about the company of the authenticated business customer.
 * The value is `undefined` if a business customer isn't authenticated.
 */
function useAuthenticatedAccountPurchasingCompany() {
  const account = useApi().authenticatedAccount;
  return useSubscription(account.purchasingCompany);
}

export { useAuthenticatedAccountCustomer, useAuthenticatedAccountPurchasingCompany };
