Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
backend mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
randysim committed Dec 29, 2023
1 parent 9ed67b9 commit cf2fd81
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/graphql/resolvers/Mutation/adminDeleteMeeting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { ApolloError } from 'apollo-server-errors';
import { deleteCalendarEvent } from '../../../googleApis/calendar';

export default async (
root,
{ meetingId },
{
adminRoleRequired,
models: { meetings, googleCalendarEvents, googleCalendars }
}
) => {
const meeting = await meetings.idLoader.load(meetingId);

if (!meeting) {
throw new ApolloError(
"There's no meeting with that id",
'MEETING_NOT_FOUND'
);
}

adminRoleRequired('charters')

/*const meetingCalEvent = await googleCalendarEvents.meetingIdLoader.load(
meeting.id
);*/
const meetingCalEvent = await googleCalendarEvents.findOne({
where: {
meetingId: meetingId,
recurringMeeting: false
}
});

const gCal = await googleCalendars.orgIdLoader.load(meeting.organizationId);

if (meetingCalEvent) {
await deleteCalendarEvent(gCal.gCalId, meetingCalEvent.gCalEventId);
await meetingCalEvent.destroy();
}

await meeting.destroy();

return true;
};
2 changes: 2 additions & 0 deletions src/graphql/resolvers/Mutation/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import addRoomToMeeting from './addRoomToMeeting';
import adminDeleteMeeting from './adminDeleteMeeting';
import alterCharter from './alterCharter';
import alterClubFairResponse from './alterClubFairResponse';
import alterEmailSettings from './alterEmailSettings';
Expand Down Expand Up @@ -51,6 +52,7 @@ import createUser from './createUser';
export default {
linkOAuthPlatform,
login,
adminDeleteMeeting,
alterCharter,
alterClubFairResponse,
alterEmailSettings,
Expand Down
3 changes: 2 additions & 1 deletion src/graphql/schema/Mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ export default gql`
createPromotedClub(orgId: Int!, blurb: String!): PromotedClub
deletePromotedClub(promotedClubId: Int!): Boolean
# --- settings ---
# --- admin ---
adminDeleteMeeting(meetingId: Int!): Boolean
alterSettings(membershipRequirement: Int!): Settings
# --- users ---
Expand Down

0 comments on commit cf2fd81

Please sign in to comment.