forked from PalisadoesFoundation/talawa-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
151 additions
and
67 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
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,50 @@ | ||
import type { InterfaceEvent } from "../../../models"; | ||
import type { | ||
Recurrance, | ||
UpdateEventInput, | ||
} from "../../../types/generatedGraphQLTypes"; | ||
import type { InterfaceRecurringEvent } from "../recurringEventHelpers/generateRecurringEventInstances"; | ||
|
||
export const getEventData = ( | ||
updateEventInputData: UpdateEventInput, | ||
event: InterfaceEvent, | ||
): InterfaceRecurringEvent => { | ||
// get the event's current data | ||
const eventCurrentData = { | ||
title: event.title, | ||
description: event.description, | ||
startDate: event.startDate, | ||
endDate: event.endDate, | ||
startTime: event.startTime, | ||
endTime: event.endTime, | ||
allDay: event.allDay, | ||
recurring: event.recurring, | ||
recurrance: event.recurrance, | ||
isPublic: event.isPublic, | ||
isRegisterable: event.isRegisterable, | ||
admins: event.admins, | ||
location: event.location, | ||
latitude: event.latitude, | ||
longitude: event.longitude, | ||
creatorId: event.creatorId, | ||
organizationId: event.organization, | ||
}; | ||
|
||
// get the updated event data | ||
const updatedEventData: InterfaceRecurringEvent = { | ||
...eventCurrentData, | ||
recurrance: eventCurrentData.recurrance as Recurrance, | ||
...Object.fromEntries( | ||
Object.entries(updateEventInputData ?? {}).filter( | ||
([value]) => value !== null, | ||
), | ||
), | ||
}; | ||
|
||
// // if the event is made infinitly recurring (i.e. endDate is null), remove it from the data | ||
// if (!updatedEventData.endDate) { | ||
// delete updatedEventData.endDate; | ||
// } | ||
|
||
return updatedEventData; | ||
}; |
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
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