Skip to content

Commit

Permalink
feat: ✨ add subscription topic: ADD_EVENT
Browse files Browse the repository at this point in the history
  • Loading branch information
CourtHive committed Apr 22, 2024
1 parent 83ae2ac commit d49823f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/constants/topicConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const ADD_DRAW_DEFINITION = 'addDrawDefinition';
export const ADD_MATCHUPS = 'addMatchUps';
export const ADD_PARTICIPANTS = 'addParticipants';
export const ADD_SCALE_ITEMS = 'addScaleItems';
export const ADD_EVENT = 'addEvent';
export const ADD_VENUE = 'addVenue';
export const AUDIT = 'audit';
export const DATA_ISSUE = 'dataIssue';
Expand Down Expand Up @@ -34,6 +35,7 @@ export const topicConstants = {
ADD_MATCHUPS,
ADD_PARTICIPANTS,
ADD_SCALE_ITEMS,
ADD_EVENT,
ADD_VENUE,
AUDIT,
DATA_ISSUE,
Expand Down
1 change: 1 addition & 0 deletions src/mutate/notifications/drawNotifications.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getPositionAssignments } from '@Query/drawDefinition/positionsGetter';
import { addNotice, deleteNotice } from '@Global/state/globalState';

// Constants and types
import { DrawDefinition, MatchUp } from '@Types/tournamentTypes';
import { SUCCESS } from '@Constants/resultConstants';
import {
Expand Down
28 changes: 28 additions & 0 deletions src/mutate/notifications/eventNotifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { addNotice } from '@Global/state/globalState';

// Constants
import { ErrorType, MISSING_EVENT } from '@Constants/errorConditionConstants';
import { ADD_EVENT } from '@Constants/topicConstants';
import { SUCCESS } from '@Constants/resultConstants';
import { Event } from '@Types/tournamentTypes';

type AddEventNoticeArgs = {
tournamentId?: string;
event?: Event;
};

export function addEventNotice({ tournamentId, event }: AddEventNoticeArgs): {
success?: boolean;
error?: ErrorType;
} {
if (!event) {
return { error: MISSING_EVENT };
}
addNotice({
payload: { tournamentId, event },
key: event.eventId,
topic: ADD_EVENT,
});

return { ...SUCCESS };
}

0 comments on commit d49823f

Please sign in to comment.