Created
June 7, 2021 12:28
-
-
Save astjohn/27f667d66db7bd297ba506681f380adc to your computer and use it in GitHub Desktop.
Travel Restriction and Entry Requirement utility functions. Used with the Sitata API for country and state-level entry requirement and travel restriction information. https://postman.sitata.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Utility functions for Entry Requirement | |
*/ | |
class EntryRequirement { | |
static types () { | |
return { | |
entryResident: 0, | |
entryForeigner: 1, | |
transitAllowed: 2, | |
testOnArrival: 3, | |
testCertificateAllowed: 4, | |
quarantineOnArrival: 5, | |
vaccinationRequired: 6, | |
insuranceRequired: 7, | |
testCertificateRequired: 8, | |
formRequired: 9 | |
} | |
} | |
static values () { | |
return { | |
no: 0, | |
yes: 1, | |
yesExceptions: 2, | |
noExceptions: 3 | |
} | |
} | |
static lowValues () { | |
let lvls = EntryRequirement.values() | |
return [lvls.yes] | |
} | |
static medValues () { | |
let lvls = EntryRequirement.values() | |
return [lvls.yesExceptions, lvls.noExceptions] | |
} | |
static highValues () { | |
let lvls = EntryRequirement.values() | |
return [lvls.no] | |
} | |
static shouldReverseStyle (type) { | |
var types = this.types() | |
switch (type) { | |
case types.quarantineOnArrival: | |
case types.testCertificateRequired: | |
case types.testOnArrival: | |
case types.vaccinationRequired: | |
case types.formRequired: | |
case types.insuranceRequired: | |
return true | |
default: | |
return false | |
} | |
} | |
} | |
export default EntryRequirement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Utility functions for Travel Restriction | |
*/ | |
class TravelRestriction { | |
static types () { | |
return { | |
airline: 0, | |
border: 1, | |
curfew: 2, | |
distancing: 3, | |
transportation: 4, | |
other: 99, | |
// recommended contact tracing app | |
borderApp: 201, | |
// non-essential shops open? | |
distShops: 401, | |
// accomodations open? | |
distAccom: 402, | |
// restaurants open? | |
distRest: 403, | |
// bars and cafes open? | |
distBars: 404, | |
// beaches and tourism spots open? | |
distTourism: 405, | |
// museums and heritage sites open | |
distMuseums: 406, | |
// personal care services open (nail salons, haircut, etc) | |
distPersonal: 407, | |
// places of worship open? | |
distWorship: 408, | |
// events allowed? | |
distEvents: 409, | |
// mask required in public? | |
distMask: 410 | |
} | |
} | |
static levels () { | |
return { | |
none: -1, | |
localized: 0, | |
moderate: 1, | |
significant: 2, | |
total: 3, | |
yes: 10, | |
yesExceptions: 11, | |
no: 12, | |
noExceptions: 13 | |
} | |
} | |
static lowValues () { | |
let lvls = TravelRestriction.levels() | |
return [lvls.localized, lvls.yes] | |
} | |
static medValues () { | |
let lvls = TravelRestriction.levels() | |
return [lvls.moderate, lvls.yesExceptions, lvls.noExceptions] | |
} | |
static highValues () { | |
let lvls = TravelRestriction.levels() | |
return [lvls.significant, lvls.total, lvls.no] | |
} | |
static shouldReverseStyle (type) { | |
var types = this.types() | |
switch (type) { | |
case types.borderApp: | |
return true | |
default: | |
return false | |
} | |
} | |
} | |
export default TravelRestriction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment