Skip to content
Snippets Groups Projects
Commit d861cda4 authored by Gregor Schulz's avatar Gregor Schulz
Browse files

invert filter logic for local

parent 83a730ef
No related branches found
No related tags found
No related merge requests found
......@@ -60,7 +60,7 @@ const toHoliEvent = (event: AppApiEvent): HoliEvent => {
}
const buildJasdAppApiUrl = (
{ limit, offset, location, remoteOnly }: FetchEventsInput,
{ limit, offset, location, localOnly }: FetchEventsInput,
): URL => {
const url = new URL(`${APP_API_BASE_URL}/search`)
url.searchParams.append('page', offset.toString())
......@@ -71,8 +71,10 @@ const buildJasdAppApiUrl = (
url.searchParams.append('includeExpiredActivities', 'false')
url.searchParams.append('permanent', 'false')
if (remoteOnly) {
url.searchParams.append('online', 'true')
if (localOnly) {
url.searchParams.append('online', 'false')
// true is returning only online events
// undefined is returning all
}
if (location) {
......@@ -128,8 +130,8 @@ const fetchEventsPage = async (
export type FetchEventsInput = {
limit: number
offset: number
localOnly: boolean
location?: string
remoteOnly?: boolean
}
export const fetchEvents = async (
......
......@@ -41,7 +41,7 @@ const SCHEMA = `
type Query {
# uses offset-based pagination as described in https://www.apollographql.com/docs/react/pagination/offset-based
events(offset: Int = 0, limit: Int = 5, location: String, remoteOnly: Boolean): EventsResponse!
events(offset: Int = 0, limit: Int = 5, location: String, localOnly: Boolean): EventsResponse!
event(id: String!): EventResponse!
}
`
......@@ -50,7 +50,7 @@ export type EventsRequest = {
limit?: number
offset?: number
location?: string
remoteOnly?: boolean
localOnly?: boolean
}
export type EventRequest = {
......@@ -69,7 +69,7 @@ const validateEventsRequestInput = (request: EventsRequest): FetchEventsInput =>
limit: limit,
offset: request.offset ?? 0,
location: request.location,
remoteOnly: request.remoteOnly,
localOnly: request.localOnly ?? false,
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment