import { Currency } from './constants';

/**
 * Validates a currency against a list of available currencies
 * Falls back to USD if the currency is not available
 *
 * @param currency - The currency to validate
 * @param availableCurrencies - Array of available currency values
 * @returns The validated currency or USD as fallback
 */
export function validateCurrency(
  currency: Currency,
  availableCurrencies: Currency[]
): Currency {
  if (availableCurrencies.includes(currency)) {
    return currency;
  }
  // If the selected currency is not available, fall back to USD
  return Currency.USD;
}
