Skip to content

Commit

Permalink
Merge pull request midday-ai#230 from midday-ai/feature/bulk-actions
Browse files Browse the repository at this point in the history
Check EU
  • Loading branch information
pontusab authored Aug 18, 2024
2 parents 2343269 + 4a42310 commit 2311a42
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
60 changes: 60 additions & 0 deletions packages/location/src/eu-countries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
export const EU_COUNTRY_CODES = [
"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",
"GB",
"GI",
"IS",
"LI",
"NO",
"CH",
"ME",
"MK",
"RS",
"TR",
"AL",
"BA",
"XK",
"AD",
"BY",
"MD",
"MC",
"RU",
"UA",
"VA",
"AX",
"FO",
"GL",
"SJ",
"IM",
"JE",
"GG",
"RS",
"ME",
"XK",
"RS",
];
9 changes: 7 additions & 2 deletions packages/location/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { headers } from "next/headers";
import countries from "./countries.json";
import flags from "./country-flag";
import { EU_COUNTRY_CODES } from "./eu-countries";

export function getCountryCode() {
return headers().get("x-vercel-ip-country") || "SE";
Expand All @@ -25,9 +26,13 @@ export function getCountryInfo() {
}

export function isEU() {
const continent = headers().get("x-vercel-ip-continent") || "EU";
const countryCode = headers().get("x-vercel-ip-country");

return continent === "EU";
if (countryCode && EU_COUNTRY_CODES.includes(countryCode)) {
return true;
}

return false;
}

export function getCountry() {
Expand Down

0 comments on commit 2311a42

Please sign in to comment.