Skip to content

Commit

Permalink
Merge pull request #350 from bakaphp/feat/implement-paginations-on-pa…
Browse files Browse the repository at this point in the history
…ge-participants-per-event

feat: implement pagination on the page of participants per event
  • Loading branch information
jaimetorresmctekk authored Nov 15, 2024
2 parents 7119c00 + 046e672 commit b05adec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/modules/event/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
GetEventResponse,
OrderBy,
EventTypeInterface,
getParticipantsByEventIdProps,
} from '../../types';

import { CREATE_EVENT_MUTATION } from '../../mutations';
Expand Down Expand Up @@ -56,14 +57,19 @@ export class Event {
return response.data.eventTypes.data;
}

public async getParticipantsByEventId(
eventId: string
): Promise<GetParticipantsByEventId> {
public async getParticipantsByEventId({
eventId,
first,
page,
}: getParticipantsByEventIdProps): Promise<GetParticipantsByEventId> {
const where = {
column: 'EVENT_VERSION_ID',
operator: 'EQ',
value: eventId,
};
const { data } = await this.client.query({
query: EVENT_PARTICIPANTS_QUERY,
variables: {
where: { column: 'EVENT_VERSION_ID', operator: 'EQ', value: eventId },
},
variables: { where, first, page },
fetchPolicy: 'network-only',
partialRefetch: true,
});
Expand Down
4 changes: 3 additions & 1 deletion src/queries/event.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ export const EVENT_TYPES_QUERY = gql`

export const EVENT_PARTICIPANTS_QUERY = gql`
query EventVersionParticipants(
$first: Int
$page: Int
$where: QueryEventVersionParticipantsWhereWhereConditions
) {
eventVersionParticipants(where: $where) {
eventVersionParticipants(first: $first, page: $page, where: $where) {
data {
participant {
id
Expand Down
6 changes: 6 additions & 0 deletions src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export type GetParticipantsByEventId = {
paginatorInfo?: PaginatorInfo;
}[];

export type getParticipantsByEventIdProps = {
eventId?: number | undefined;
first?: number;
page?: number;
}

export interface EventCategoryInterface {
id: string;
name: string;
Expand Down

0 comments on commit b05adec

Please sign in to comment.