add additional blocked countries

This commit is contained in:
Tyler Shipe 2021-06-10 11:18:13 -04:00
parent b3f5d132e6
commit 821c24fa45
1 changed files with 31 additions and 1 deletions

View File

@ -1,5 +1,35 @@
import { useEffect, useState } from 'react'
const SANCTIONED_COUNTRIES = [
{ country: 'Antigua and Barbuda', code: 'AG' },
{ country: 'Algeria', code: 'DZ' },
{ country: 'Bangladesh', code: 'BD' },
{ country: 'Bolivia', code: 'BO' },
{ country: 'Belarus', code: 'BY' },
{ country: 'Burundi', code: 'BI' },
{ country: 'Burma (Myanmar)', code: 'MM' },
{ country: "Cote D'Ivoire (Ivory Coast)", code: 'CI' },
{ country: 'Cuba', code: 'CU' },
{ country: 'Democratic Republic of Congo', code: 'CD' },
{ country: 'Ecuador', code: 'EC' },
{ country: 'Iran', code: 'IR' },
{ country: 'Iraq', code: 'IQ' },
{ country: 'Liberia', code: 'LR' },
{ country: 'Libya', code: 'LY' },
{ country: 'Mali', code: 'ML' },
{ country: 'Morocco', code: 'MA' },
{ country: 'Nepal', code: 'NP' },
{ country: 'North Korea', code: 'KP' },
{ country: 'Somalia', code: 'SO' },
{ country: 'Sudan', code: 'SD' },
{ country: 'Syria', code: 'SY' },
{ country: 'Venezuela', code: 'VE' },
{ country: 'Yemen', code: 'YE' },
{ country: 'Zimbabwe', code: 'ZW' },
]
const SANCTIONED_COUNTRY_CODES = SANCTIONED_COUNTRIES.map(({ code }) => code)
export default function useIpAddress() {
const [ipAllowed, setIpAllowed] = useState(true)
@ -11,7 +41,7 @@ export default function useIpAddress() {
const ipCountryCode = ipLocation ? ipLocation[1] : ''
if (ipCountryCode) {
setIpAllowed(ipCountryCode !== 'US')
setIpAllowed(!SANCTIONED_COUNTRY_CODES.includes(ipCountryCode))
}
}