From fe885ae6def29a1a32dcb24cbe026fc91fa10e46 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Thu, 1 Apr 2021 16:45:12 +0800 Subject: [PATCH] Util to get list of countries --- ui/util/country.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 ui/util/country.js diff --git a/ui/util/country.js b/ui/util/country.js new file mode 100644 index 000000000..1a5c1a287 --- /dev/null +++ b/ui/util/country.js @@ -0,0 +1,18 @@ +import { countries as countryData } from 'country-data'; + +export const COUNTRIES = Array.from( + new Set( + countryData.all + .filter((country) => country.status !== 'deleted') + .map((country) => country.name) + .sort((a, b) => { + if (a > b) { + return 1; + } + if (b > a) { + return -1; + } + return 0; + }) + ) +);