export const EU_COUNTRIES = [
  "FR", "BE", "NL", "ES", "IT", "DE", "PT", "IE", "AT", "LU", "DK", "SE", "FI", "PL", "CZ", "GR",
];

export type ShippingConfig = {
  freeThreshold: number;
  morocco: number;
  europe: number;
  world: number;
};

export function shippingFor(country: string, subtotal: number, config: ShippingConfig) {
  if (country === "MA") {
    return subtotal >= config.freeThreshold ? 0 : config.morocco;
  }
  if (EU_COUNTRIES.includes(country)) return config.europe;
  return config.world;
}

export function isFreeShipping(country: string, subtotal: number, config: ShippingConfig) {
  return country === "MA" && subtotal >= config.freeThreshold;
}
