Convert location "Online" into type "Online" (#525)

This commit is contained in:
Salvador de la Puente González 2020-04-15 17:29:20 +02:00 committed by GitHub
parent 84baa198df
commit a0e5651f1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 12 deletions

View File

@ -65,7 +65,7 @@ function getTypes (record: any): CommunityEventType[] {
return noTypes ? [COMMUNITY_EVENT_TYPES.talks] : communityEventTypes
}
function filterWithWhitelist<W> (list: any[], whitelist: W[]): W[] {
function filterWithWhitelist<W> (list: any[], whitelist: readonly W[]): W[] {
return list.filter((type): type is W => whitelist.includes(type))
}
@ -102,7 +102,7 @@ function getPlace (record: any) {
}
function getLocation (_record: any): WorldLocation {
const options: WorldLocation[] = WORLD_LOCATION_OPTIONS
const options = WORLD_LOCATION_OPTIONS
return options[Math.floor(Math.random() * options.length)]
}

View File

@ -5,15 +5,14 @@ const COMMUNITY_EVENT_TYPES = Object.freeze({
industryEvent: 'Industry Event',
workshop: 'Workshop',
talks: 'Talks',
virtualEvent: 'Virtual Event'
online: 'Online'
} as const)
const WORLD_LOCATIONS = Object.freeze({
americas: 'Americas',
asiaPacific: 'Asia Pacific',
europe: 'Europe',
africa: 'Africa',
online: 'Online'
africa: 'Africa'
} as const)
type CommunityEventSet = 'past'|'upcoming'
@ -30,22 +29,21 @@ type CommunityEvent = {
to: string
}
const WORLD_LOCATION_OPTIONS: WorldLocation[] = [
const WORLD_LOCATION_OPTIONS = Object.freeze([
WORLD_LOCATIONS.americas,
WORLD_LOCATIONS.asiaPacific,
WORLD_LOCATIONS.europe,
WORLD_LOCATIONS.africa,
WORLD_LOCATIONS.online
]
const COMMUNITY_EVENT_TYPE_OPTIONS: CommunityEventType[] = [
WORLD_LOCATIONS.africa
])
const COMMUNITY_EVENT_TYPE_OPTIONS = Object.freeze([
COMMUNITY_EVENT_TYPES.hackathon,
COMMUNITY_EVENT_TYPES.camp,
COMMUNITY_EVENT_TYPES.unconference,
COMMUNITY_EVENT_TYPES.industryEvent,
COMMUNITY_EVENT_TYPES.workshop,
COMMUNITY_EVENT_TYPES.talks,
COMMUNITY_EVENT_TYPES.virtualEvent
]
COMMUNITY_EVENT_TYPES.online
])
export {
CommunityEvent,