All files / src/constants countries.ts

100% Statements 42/42
100% Branches 3/3
100% Functions 0/0
100% Lines 42/42

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 651x             1x   1x   1x         1x 1x 1x 1x   1x       1x 1x   1x           1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * @group Constants
 * @groupDescription Country lists derived from the compact `countryData` table. Split out of
 * `constants/common.ts` so that importing app constants (e.g. `CACHE`) does not
 * pull the country table into dependency-light bundles such as the
 * background service worker.
 * @source
 */
 
import { COUNTRY_DATA } from '@/constants/countryData';
 
/**
 * Supported countries for location-based features such as currency and shipping filters.
 * Sourced from {@link COUNTRY_DATA} (full ISO 3166-1 alpha-2 list) and sorted alphabetically
 * by country name.
 * @source
 */
export const COUNTRIES = Object.entries(COUNTRY_DATA)
  .map(([code, [name]]) => ({ code, name }))
  .sort((a, b) => a.name.localeCompare(b.name));
 
/**
 * Supplier country options available for filtering in the drawer search panel.
 * Derived from {@link COUNTRIES} (already sorted alphabetically by name).
 * @source
 */
export const SUPPLIER_COUNTRY_OPTIONS = COUNTRIES.map(({ code, name }) => ({ code, label: name }));
 
/**
 * ISO 3166-1 alpha-2 codes of the 27 EU member states. The country table carries no EU
 * membership, so this legally-defined set is hardcoded.
 * Used to evaluate "EU-only" purchase restrictions: a user whose location is not in
 * this set cannot buy an EU-only product.
 * @source
 */
export const EU_COUNTRY_CODES: ReadonlySet<string> = new Set([
  'AT',
  'BE',
  'BG',
  'HR',
  'CY',
  'CZ',
  'DK',
  'EE',
  'FI',
  'FR',
  'DE',
  'GR',
  'HU',
  'IE',
  'IT',
  'LV',
  'LT',
  'LU',
  'MT',
  'NL',
  'PL',
  'PT',
  'RO',
  'SK',
  'SI',
  'ES',
  'SE',
]);