use singular events in upcoming events
This commit is contained in:
@ -89,7 +89,7 @@ export const futureEventsQuery = graphql(`
|
||||
}
|
||||
`);
|
||||
|
||||
export function getSingularEvents(events: EventFragment[]) {
|
||||
export function getSingularEvents(events: EventFragment[]): SingularEvent[] {
|
||||
return events
|
||||
.map((event) => {
|
||||
return event.occurrences.map((occurrence) => {
|
||||
@ -100,6 +100,12 @@ export function getSingularEvents(events: EventFragment[]) {
|
||||
})
|
||||
.flat();
|
||||
}
|
||||
|
||||
export function sortSingularEvents(events: SingularEvent[]) {
|
||||
return events.sort((a, b) =>
|
||||
compareAsc(new Date(a.occurrence.start), new Date(b.occurrence.start))
|
||||
);
|
||||
}
|
||||
interface EventsByDate {
|
||||
[yearMonth: string]: {
|
||||
[week: string]: {
|
||||
@ -109,9 +115,7 @@ interface EventsByDate {
|
||||
}
|
||||
|
||||
export function organizeEventsByDate(events: SingularEvent[]): EventsByDate {
|
||||
const sortedEvents = events.sort((a, b) =>
|
||||
compareAsc(new Date(a.occurrence.start), new Date(b.occurrence.start))
|
||||
);
|
||||
const sortedEvents = sortSingularEvents(events);
|
||||
|
||||
const eventsByDate: EventsByDate = {};
|
||||
|
||||
|
Reference in New Issue
Block a user