This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add preferred events to the frontend (#400)
- Loading branch information
1 parent
6095334
commit d7fc0a9
Showing
6 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { EventId } from '@wca/helpers' | ||
|
||
export function getPreferredEventsMock(): EventId[] { | ||
const events = [ | ||
'222', | ||
'333', | ||
'444', | ||
'555', | ||
'666', | ||
'777', | ||
'333bf', | ||
'333fm', | ||
'333oh', | ||
'clock', | ||
'minx', | ||
'pyram', | ||
'skewb', | ||
'sq1', | ||
'444bf', | ||
'555bf', | ||
'333mbf', | ||
] | ||
const end = Math.round(Math.random() * events.length) | ||
const start = Math.round(Math.random() * end) | ||
return events.slice(start, end) as EventId[] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { EventId } from '@wca/helpers' | ||
import externalServiceFetch from '../../helper/external_service_fetch' | ||
import { preferredEventsRoute } from '../../helper/routes' | ||
import { getPreferredEventsMock } from '../../mocks/get_preferred_events' | ||
|
||
export default async function getPreferredEvents(): Promise<EventId[]> { | ||
if (process.env.NODE_ENV === 'production') { | ||
return externalServiceFetch(preferredEventsRoute) | ||
} | ||
// returns a random selection of events as a mock | ||
return getPreferredEventsMock() | ||
} |
This file contains 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
This file contains 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