simplify some type checks by fixing graphql schema

This commit is contained in:
2024-05-14 21:36:05 +02:00
parent ba93e7e783
commit fa3ebdb91c
7 changed files with 69 additions and 222 deletions

View File

@ -49,9 +49,9 @@ class EventCategory(models.Model):
panels = [FieldPanel("name"), FieldPanel("slug"), FieldPanel("show_in_filters")]
graphql_fields = [
GraphQLString("name"),
GraphQLString("slug"),
GraphQLBoolean("show_in_filters"),
GraphQLString("name", required=True),
GraphQLString("slug", required=True),
GraphQLBoolean("show_in_filters", required=True),
]
class Meta:
@ -171,8 +171,20 @@ class EventPage(Page):
GraphQLInt("price_regular"),
GraphQLInt("price_student"),
GraphQLInt("price_member"),
GraphQLCollection(GraphQLForeignKey, "categories", "events.EventCategory"),
GraphQLCollection(GraphQLForeignKey, "occurrences", "events.EventOccurrence"),
GraphQLCollection(
GraphQLForeignKey,
"categories",
"events.EventCategory",
required=True,
item_required=True,
),
GraphQLCollection(
GraphQLForeignKey,
"occurrences",
"events.EventOccurrence",
required=True,
item_required=True,
),
]
@ -195,7 +207,7 @@ class EventOccurrence(Orderable):
]
graphql_fields = [
GraphQLString("start"),
GraphQLString("start", required=True),
GraphQLString("end"),
GraphQLForeignKey("venue", "venues.VenuePage"),
]

View File

@ -1,3 +1,5 @@
import "server-only"
import { cacheExchange, createClient, fetchExchange } from "@urql/core";
import { registerUrql } from "@urql/next/rsc";

View File

@ -1,6 +1,6 @@
"use client";
import { useQueryState, parseAsStringLiteral } from "nuqs";
import { useQueryState, parseAsStringLiteral, parseAsString } from "nuqs";
import { EventItem } from "./EventItem";
import { EventFilter } from "./EventFilter";
import {
@ -32,22 +32,12 @@ export const EventContainer = ({
);
const filterableCategories = eventCategories.filter((x) => x.showInFilters);
const filterableCategorySlugs: string[] = filterableCategories
.filter((x) => "slug" in x && typeof x.slug === "string")
.map((x) => x.slug);
const [category, setCategory] = useQueryState(
"category",
parseAsStringLiteral(filterableCategorySlugs).withDefault(null)
);
const [category, setCategory] = useQueryState("category", parseAsString);
const filteredEvents = events.filter(
(x) =>
!category ||
x.categories
?.filter((x) => x !== null)
.map((eventCategory: EventCategory) => eventCategory.slug)
.includes(category)
x.categories.map((eventCategory) => eventCategory.slug).includes(category)
);
return (

View File

@ -1,4 +1,4 @@
import { EventCategoryFragment } from "@/lib/event";
import { EventCategory } from "@/lib/event";
import styles from "./eventFilter.module.scss";
@ -7,9 +7,9 @@ export const EventFilter = ({
setCategory,
activeCategory,
}: {
eventCategories: EventCategoryFragment[];
setCategory: (slug: string) => void;
activeCategory?: string;
eventCategories: EventCategory[];
setCategory: (slug: string | null) => void;
activeCategory: string | null;
}) => {
return (
<div className={styles.eventFilter}>

View File

@ -16,11 +16,7 @@ export const EventHeader = ({ event }: { event: EventFragment }) => {
<div>Medlemspris: {event.priceMember}</div>
<div>
Kategorier:{" "}
{event.categories &&
event.categories
.filter((x) => x != null)
.map((x: EventCategoryFragment) => x.name)
.join(", ")}
{event.categories && event.categories.map((x) => x.name).join(", ")}
</div>
</div>
</div>

View File

@ -36,13 +36,12 @@ export type Scalars = {
UUID: { input: any; output: any; }
};
export type AssociationIndex = PageInterface & {
__typename?: 'AssociationIndex';
export type Association = PageInterface & {
__typename?: 'Association';
aliasOf?: Maybe<Page>;
aliases: Array<Page>;
ancestors: Array<PageInterface>;
associationindex?: Maybe<AssociationIndex>;
associationpage?: Maybe<AssociationPage>;
association?: Maybe<Association>;
children: Array<PageInterface>;
contentType: Scalars['String']['output'];
depth?: Maybe<Scalars['Int']['output']>;
@ -85,7 +84,7 @@ export type AssociationIndex = PageInterface & {
};
export type AssociationIndexAncestorsArgs = {
export type AssociationAncestorsArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
@ -94,7 +93,7 @@ export type AssociationIndexAncestorsArgs = {
};
export type AssociationIndexChildrenArgs = {
export type AssociationChildrenArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
@ -103,7 +102,7 @@ export type AssociationIndexChildrenArgs = {
};
export type AssociationIndexDescendantsArgs = {
export type AssociationDescendantsArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
@ -112,7 +111,7 @@ export type AssociationIndexDescendantsArgs = {
};
export type AssociationIndexNextSiblingsArgs = {
export type AssociationNextSiblingsArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
@ -121,7 +120,7 @@ export type AssociationIndexNextSiblingsArgs = {
};
export type AssociationIndexPreviousSiblingsArgs = {
export type AssociationPreviousSiblingsArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
@ -130,109 +129,7 @@ export type AssociationIndexPreviousSiblingsArgs = {
};
export type AssociationIndexSiblingsArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
order?: InputMaybe<Scalars['String']['input']>;
searchQuery?: InputMaybe<Scalars['String']['input']>;
};
export type AssociationPage = PageInterface & {
__typename?: 'AssociationPage';
aliasOf?: Maybe<Page>;
aliases: Array<Page>;
ancestors: Array<PageInterface>;
associationindex?: Maybe<AssociationIndex>;
associationpage?: Maybe<AssociationPage>;
children: Array<PageInterface>;
contentType: Scalars['String']['output'];
depth?: Maybe<Scalars['Int']['output']>;
descendants: Array<PageInterface>;
draftTitle: Scalars['String']['output'];
eventindex?: Maybe<EventIndex>;
eventpage?: Maybe<EventPage>;
expireAt?: Maybe<Scalars['DateTime']['output']>;
expired: Scalars['Boolean']['output'];
firstPublishedAt?: Maybe<Scalars['DateTime']['output']>;
genericpage?: Maybe<GenericPage>;
goLiveAt?: Maybe<Scalars['DateTime']['output']>;
hasUnpublishedChanges: Scalars['Boolean']['output'];
homepage?: Maybe<HomePage>;
id?: Maybe<Scalars['ID']['output']>;
lastPublishedAt?: Maybe<Scalars['DateTime']['output']>;
latestRevisionCreatedAt?: Maybe<Scalars['DateTime']['output']>;
live: Scalars['Boolean']['output'];
locked?: Maybe<Scalars['Boolean']['output']>;
lockedAt?: Maybe<Scalars['DateTime']['output']>;
nextSiblings: Array<PageInterface>;
numchild: Scalars['Int']['output'];
pageType?: Maybe<Scalars['String']['output']>;
parent?: Maybe<PageInterface>;
path: Scalars['String']['output'];
previousSiblings: Array<PageInterface>;
searchDescription?: Maybe<Scalars['String']['output']>;
searchScore?: Maybe<Scalars['Float']['output']>;
seoTitle: Scalars['String']['output'];
showInMenus: Scalars['Boolean']['output'];
siblings: Array<PageInterface>;
sitesRootedHere: Array<SiteObjectType>;
slug: Scalars['String']['output'];
title: Scalars['String']['output'];
translationKey: Scalars['UUID']['output'];
url?: Maybe<Scalars['String']['output']>;
urlPath: Scalars['String']['output'];
venueindex?: Maybe<VenueIndex>;
venuepage?: Maybe<VenuePage>;
};
export type AssociationPageAncestorsArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
order?: InputMaybe<Scalars['String']['input']>;
searchQuery?: InputMaybe<Scalars['String']['input']>;
};
export type AssociationPageChildrenArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
order?: InputMaybe<Scalars['String']['input']>;
searchQuery?: InputMaybe<Scalars['String']['input']>;
};
export type AssociationPageDescendantsArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
order?: InputMaybe<Scalars['String']['input']>;
searchQuery?: InputMaybe<Scalars['String']['input']>;
};
export type AssociationPageNextSiblingsArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
order?: InputMaybe<Scalars['String']['input']>;
searchQuery?: InputMaybe<Scalars['String']['input']>;
};
export type AssociationPagePreviousSiblingsArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
order?: InputMaybe<Scalars['String']['input']>;
searchQuery?: InputMaybe<Scalars['String']['input']>;
};
export type AssociationPageSiblingsArgs = {
export type AssociationSiblingsArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
@ -382,9 +279,9 @@ export type EmbedBlock = StreamFieldInterface & {
export type EventCategory = {
__typename?: 'EventCategory';
id?: Maybe<Scalars['ID']['output']>;
name?: Maybe<Scalars['String']['output']>;
showInFilters?: Maybe<Scalars['Boolean']['output']>;
slug?: Maybe<Scalars['String']['output']>;
name: Scalars['String']['output'];
showInFilters: Scalars['Boolean']['output'];
slug: Scalars['String']['output'];
};
export type EventIndex = PageInterface & {
@ -392,8 +289,7 @@ export type EventIndex = PageInterface & {
aliasOf?: Maybe<Page>;
aliases: Array<Page>;
ancestors: Array<PageInterface>;
associationindex?: Maybe<AssociationIndex>;
associationpage?: Maybe<AssociationPage>;
association?: Maybe<Association>;
children: Array<PageInterface>;
contentType: Scalars['String']['output'];
depth?: Maybe<Scalars['Int']['output']>;
@ -493,24 +389,18 @@ export type EventOccurrence = {
__typename?: 'EventOccurrence';
end?: Maybe<Scalars['String']['output']>;
id?: Maybe<Scalars['ID']['output']>;
start?: Maybe<Scalars['String']['output']>;
start: Scalars['String']['output'];
venue?: Maybe<VenuePage>;
};
export type EventOrganizer = {
__typename?: 'EventOrganizer';
id?: Maybe<Scalars['ID']['output']>;
};
export type EventPage = PageInterface & {
__typename?: 'EventPage';
aliasOf?: Maybe<Page>;
aliases: Array<Page>;
ancestors: Array<PageInterface>;
associationindex?: Maybe<AssociationIndex>;
associationpage?: Maybe<AssociationPage>;
association?: Maybe<Association>;
body?: Maybe<Array<Maybe<StreamFieldInterface>>>;
categories?: Maybe<Array<Maybe<EventCategory>>>;
categories: Array<EventCategory>;
children: Array<PageInterface>;
contentType: Scalars['String']['output'];
depth?: Maybe<Scalars['Int']['output']>;
@ -535,8 +425,7 @@ export type EventPage = PageInterface & {
lockedAt?: Maybe<Scalars['DateTime']['output']>;
nextSiblings: Array<PageInterface>;
numchild: Scalars['Int']['output'];
occurrences?: Maybe<Array<Maybe<EventOccurrence>>>;
organizers?: Maybe<Array<Maybe<EventOrganizer>>>;
occurrences: Array<EventOccurrence>;
pageType?: Maybe<Scalars['String']['output']>;
parent?: Maybe<PageInterface>;
path: Scalars['String']['output'];
@ -615,15 +504,6 @@ export type EventPageOccurrencesArgs = {
};
export type EventPageOrganizersArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
order?: InputMaybe<Scalars['String']['input']>;
searchQuery?: InputMaybe<Scalars['String']['input']>;
};
export type EventPagePreviousSiblingsArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
@ -655,8 +535,7 @@ export type GenericPage = PageInterface & {
aliasOf?: Maybe<Page>;
aliases: Array<Page>;
ancestors: Array<PageInterface>;
associationindex?: Maybe<AssociationIndex>;
associationpage?: Maybe<AssociationPage>;
association?: Maybe<Association>;
body?: Maybe<Array<Maybe<StreamFieldInterface>>>;
children: Array<PageInterface>;
contentType: Scalars['String']['output'];
@ -758,8 +637,7 @@ export type HomePage = PageInterface & {
aliasOf?: Maybe<Page>;
aliases: Array<Page>;
ancestors: Array<PageInterface>;
associationindex?: Maybe<AssociationIndex>;
associationpage?: Maybe<AssociationPage>;
association?: Maybe<Association>;
children: Array<PageInterface>;
contentType: Scalars['String']['output'];
depth?: Maybe<Scalars['Int']['output']>;
@ -954,8 +832,7 @@ export type Page = PageInterface & {
aliasOf?: Maybe<Page>;
aliases: Array<Page>;
ancestors: Array<PageInterface>;
associationindex?: Maybe<AssociationIndex>;
associationpage?: Maybe<AssociationPage>;
association?: Maybe<Association>;
children: Array<PageInterface>;
contentType: Scalars['String']['output'];
depth?: Maybe<Scalars['Int']['output']>;
@ -1172,8 +1049,6 @@ export type Query = {
documents: Array<DocumentObjectType>;
eventCategories?: Maybe<Array<Maybe<EventCategory>>>;
eventCategory?: Maybe<EventCategory>;
eventOrganizer?: Maybe<EventOrganizer>;
eventOrganizers?: Maybe<Array<Maybe<EventOrganizer>>>;
image?: Maybe<ImageObjectType>;
imageType: Scalars['String']['output'];
images: Array<ImageObjectType>;
@ -1225,20 +1100,6 @@ export type QueryEventCategoryArgs = {
};
export type QueryEventOrganizerArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
};
export type QueryEventOrganizersArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
limit?: InputMaybe<Scalars['PositiveInt']['input']>;
offset?: InputMaybe<Scalars['PositiveInt']['input']>;
order?: InputMaybe<Scalars['String']['input']>;
searchQuery?: InputMaybe<Scalars['String']['input']>;
};
export type QueryImageArgs = {
id?: InputMaybe<Scalars['ID']['input']>;
};
@ -1348,7 +1209,7 @@ export type RichTextBlock = StreamFieldInterface & {
value: Scalars['String']['output'];
};
export type Search = AssociationIndex | AssociationPage | EventCategory | EventIndex | EventOccurrence | EventOrganizer | EventPage | GenericPage | HomePage | Page | VenueIndex | VenuePage;
export type Search = Association | EventCategory | EventIndex | EventOccurrence | EventPage | GenericPage | HomePage | Page | VenueIndex | VenuePage;
export type SiteObjectType = {
__typename?: 'SiteObjectType';
@ -1470,8 +1331,7 @@ export type VenueIndex = PageInterface & {
aliasOf?: Maybe<Page>;
aliases: Array<Page>;
ancestors: Array<PageInterface>;
associationindex?: Maybe<AssociationIndex>;
associationpage?: Maybe<AssociationPage>;
association?: Maybe<Association>;
children: Array<PageInterface>;
contentType: Scalars['String']['output'];
depth?: Maybe<Scalars['Int']['output']>;
@ -1572,8 +1432,7 @@ export type VenuePage = PageInterface & {
aliasOf?: Maybe<Page>;
aliases: Array<Page>;
ancestors: Array<PageInterface>;
associationindex?: Maybe<AssociationIndex>;
associationpage?: Maybe<AssociationPage>;
association?: Maybe<Association>;
body?: Maybe<Array<Maybe<StreamFieldInterface>>>;
capabilityAudio?: Maybe<Scalars['String']['output']>;
capabilityAudioVideo?: Maybe<Scalars['String']['output']>;
@ -1686,14 +1545,14 @@ export type GenericFragment = { __typename: 'GenericPage', id?: string | null, u
export type AllGenericSlugsQueryVariables = Exact<{ [key: string]: never; }>;
export type AllGenericSlugsQuery = { __typename?: 'Query', pages: Array<{ __typename?: 'AssociationIndex', id?: string | null, urlPath: string } | { __typename?: 'AssociationPage', id?: string | null, urlPath: string } | { __typename?: 'EventIndex', id?: string | null, urlPath: string } | { __typename?: 'EventPage', id?: string | null, urlPath: string } | { __typename?: 'GenericPage', id?: string | null, urlPath: string } | { __typename?: 'HomePage', id?: string | null, urlPath: string } | { __typename?: 'Page', id?: string | null, urlPath: string } | { __typename?: 'VenueIndex', id?: string | null, urlPath: string } | { __typename?: 'VenuePage', id?: string | null, urlPath: string }> };
export type AllGenericSlugsQuery = { __typename?: 'Query', pages: Array<{ __typename?: 'Association', id?: string | null, urlPath: string } | { __typename?: 'EventIndex', id?: string | null, urlPath: string } | { __typename?: 'EventPage', id?: string | null, urlPath: string } | { __typename?: 'GenericPage', id?: string | null, urlPath: string } | { __typename?: 'HomePage', id?: string | null, urlPath: string } | { __typename?: 'Page', id?: string | null, urlPath: string } | { __typename?: 'VenueIndex', id?: string | null, urlPath: string } | { __typename?: 'VenuePage', id?: string | null, urlPath: string }> };
export type GenericPageByUrlQueryVariables = Exact<{
urlPath: Scalars['String']['input'];
}>;
export type GenericPageByUrlQuery = { __typename?: 'Query', page?: { __typename?: 'AssociationIndex' } | { __typename?: 'AssociationPage' } | { __typename?: 'EventIndex' } | { __typename?: 'EventPage' } | (
export type GenericPageByUrlQuery = { __typename?: 'Query', page?: { __typename?: 'Association' } | { __typename?: 'EventIndex' } | { __typename?: 'EventPage' } | (
{ __typename?: 'GenericPage' }
& { ' $fragmentRefs'?: { 'GenericFragment': GenericFragment } }
) | { __typename?: 'HomePage' } | { __typename?: 'Page' } | { __typename?: 'VenueIndex' } | { __typename?: 'VenuePage' } | null };
@ -1701,14 +1560,14 @@ export type GenericPageByUrlQuery = { __typename?: 'Query', page?: { __typename?
export type AllEventSlugsQueryVariables = Exact<{ [key: string]: never; }>;
export type AllEventSlugsQuery = { __typename?: 'Query', pages: Array<{ __typename?: 'AssociationIndex', id?: string | null, slug: string } | { __typename?: 'AssociationPage', id?: string | null, slug: string } | { __typename?: 'EventIndex', id?: string | null, slug: string } | { __typename?: 'EventPage', id?: string | null, slug: string } | { __typename?: 'GenericPage', id?: string | null, slug: string } | { __typename?: 'HomePage', id?: string | null, slug: string } | { __typename?: 'Page', id?: string | null, slug: string } | { __typename?: 'VenueIndex', id?: string | null, slug: string } | { __typename?: 'VenuePage', id?: string | null, slug: string }> };
export type AllEventSlugsQuery = { __typename?: 'Query', pages: Array<{ __typename?: 'Association', id?: string | null, slug: string } | { __typename?: 'EventIndex', id?: string | null, slug: string } | { __typename?: 'EventPage', id?: string | null, slug: string } | { __typename?: 'GenericPage', id?: string | null, slug: string } | { __typename?: 'HomePage', id?: string | null, slug: string } | { __typename?: 'Page', id?: string | null, slug: string } | { __typename?: 'VenueIndex', id?: string | null, slug: string } | { __typename?: 'VenuePage', id?: string | null, slug: string }> };
export type EventBySlugQueryVariables = Exact<{
slug: Scalars['String']['input'];
}>;
export type EventBySlugQuery = { __typename?: 'Query', event?: { __typename?: 'AssociationIndex' } | { __typename?: 'AssociationPage' } | { __typename?: 'EventIndex' } | (
export type EventBySlugQuery = { __typename?: 'Query', event?: { __typename?: 'Association' } | { __typename?: 'EventIndex' } | (
{ __typename?: 'EventPage' }
& { ' $fragmentRefs'?: { 'EventFragment': EventFragment } }
) | { __typename?: 'GenericPage' } | { __typename?: 'HomePage' } | { __typename?: 'Page' } | { __typename?: 'VenueIndex' } | { __typename?: 'VenuePage' } | null };
@ -1716,14 +1575,14 @@ export type EventBySlugQuery = { __typename?: 'Query', event?: { __typename?: 'A
export type AllVenueSlugsQueryVariables = Exact<{ [key: string]: never; }>;
export type AllVenueSlugsQuery = { __typename?: 'Query', pages: Array<{ __typename?: 'AssociationIndex', id?: string | null, slug: string } | { __typename?: 'AssociationPage', id?: string | null, slug: string } | { __typename?: 'EventIndex', id?: string | null, slug: string } | { __typename?: 'EventPage', id?: string | null, slug: string } | { __typename?: 'GenericPage', id?: string | null, slug: string } | { __typename?: 'HomePage', id?: string | null, slug: string } | { __typename?: 'Page', id?: string | null, slug: string } | { __typename?: 'VenueIndex', id?: string | null, slug: string } | { __typename?: 'VenuePage', id?: string | null, slug: string }> };
export type AllVenueSlugsQuery = { __typename?: 'Query', pages: Array<{ __typename?: 'Association', id?: string | null, slug: string } | { __typename?: 'EventIndex', id?: string | null, slug: string } | { __typename?: 'EventPage', id?: string | null, slug: string } | { __typename?: 'GenericPage', id?: string | null, slug: string } | { __typename?: 'HomePage', id?: string | null, slug: string } | { __typename?: 'Page', id?: string | null, slug: string } | { __typename?: 'VenueIndex', id?: string | null, slug: string } | { __typename?: 'VenuePage', id?: string | null, slug: string }> };
export type VenueBySlugQueryVariables = Exact<{
slug: Scalars['String']['input'];
}>;
export type VenueBySlugQuery = { __typename?: 'Query', venue?: { __typename?: 'AssociationIndex' } | { __typename?: 'AssociationPage' } | { __typename?: 'EventIndex' } | { __typename?: 'EventPage' } | { __typename?: 'GenericPage' } | { __typename?: 'HomePage' } | { __typename?: 'Page' } | { __typename?: 'VenueIndex' } | (
export type VenueBySlugQuery = { __typename?: 'Query', venue?: { __typename?: 'Association' } | { __typename?: 'EventIndex' } | { __typename?: 'EventPage' } | { __typename?: 'GenericPage' } | { __typename?: 'HomePage' } | { __typename?: 'Page' } | { __typename?: 'VenueIndex' } | (
{ __typename?: 'VenuePage' }
& { ' $fragmentRefs'?: { 'VenueFragment': VenueFragment } }
) | null };
@ -1733,7 +1592,7 @@ export type VenueFragment = { __typename: 'VenuePage', id?: string | null, slug:
export type AllVenuesQueryVariables = Exact<{ [key: string]: never; }>;
export type AllVenuesQuery = { __typename?: 'Query', venues: Array<{ __typename?: 'AssociationIndex' } | { __typename?: 'AssociationPage' } | { __typename?: 'EventIndex' } | { __typename?: 'EventPage' } | { __typename?: 'GenericPage' } | { __typename?: 'HomePage' } | { __typename?: 'Page' } | { __typename?: 'VenueIndex' } | (
export type AllVenuesQuery = { __typename?: 'Query', venues: Array<{ __typename?: 'Association' } | { __typename?: 'EventIndex' } | { __typename?: 'EventPage' } | { __typename?: 'GenericPage' } | { __typename?: 'HomePage' } | { __typename?: 'Page' } | { __typename?: 'VenueIndex' } | (
{ __typename?: 'VenuePage' }
& { ' $fragmentRefs'?: { 'VenueFragment': VenueFragment } }
)> };
@ -1741,20 +1600,20 @@ export type AllVenuesQuery = { __typename?: 'Query', venues: Array<{ __typename?
export type HomeQueryVariables = Exact<{ [key: string]: never; }>;
export type HomeQuery = { __typename?: 'Query', events: Array<{ __typename?: 'AssociationIndex' } | { __typename?: 'AssociationPage' } | { __typename?: 'EventIndex' } | (
export type HomeQuery = { __typename?: 'Query', events: Array<{ __typename?: 'Association' } | { __typename?: 'EventIndex' } | (
{ __typename?: 'EventPage' }
& { ' $fragmentRefs'?: { 'EventFragment': EventFragment } }
) | { __typename?: 'GenericPage' } | { __typename?: 'HomePage' } | { __typename?: 'Page' } | { __typename?: 'VenueIndex' } | { __typename?: 'VenuePage' }> };
export type EventFragment = { __typename: 'EventPage', id?: string | null, slug: string, title: string, facebookUrl?: string | null, ticketUrl?: string | null, priceRegular?: number | null, priceMember?: number | null, priceStudent?: number | null, body?: Array<{ __typename?: 'BlockQuoteBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'BooleanBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'CharBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'ChoiceBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'DateBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'DateTimeBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'DecimalBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'DocumentChooserBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'EmailBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'EmbedBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'FloatBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'ImageChooserBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'IntegerBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'ListBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'PageChooserBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'RawHTMLBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'RegexBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'RichTextBlock', rawValue: string, value: string, id?: string | null, blockType: string, field: string } | { __typename?: 'StaticBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'StreamBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'StreamFieldBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'StructBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'TextBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'TimeBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'URLBlock', id?: string | null, blockType: string, field: string } | null> | null, featuredImage?: { __typename?: 'ImageObjectType', url: string, width: number, height: number } | null, categories?: Array<{ __typename?: 'EventCategory', name?: string | null, slug?: string | null } | null> | null, occurrences?: Array<{ __typename: 'EventOccurrence', id?: string | null, start?: string | null, end?: string | null, venue?: { __typename: 'VenuePage', id?: string | null, slug: string, title: string } | null } | null> | null } & { ' $fragmentName'?: 'EventFragment' };
export type EventFragment = { __typename: 'EventPage', id?: string | null, slug: string, title: string, facebookUrl?: string | null, ticketUrl?: string | null, priceRegular?: number | null, priceMember?: number | null, priceStudent?: number | null, body?: Array<{ __typename?: 'BlockQuoteBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'BooleanBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'CharBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'ChoiceBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'DateBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'DateTimeBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'DecimalBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'DocumentChooserBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'EmailBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'EmbedBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'FloatBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'ImageChooserBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'IntegerBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'ListBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'PageChooserBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'RawHTMLBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'RegexBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'RichTextBlock', rawValue: string, value: string, id?: string | null, blockType: string, field: string } | { __typename?: 'StaticBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'StreamBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'StreamFieldBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'StructBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'TextBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'TimeBlock', id?: string | null, blockType: string, field: string } | { __typename?: 'URLBlock', id?: string | null, blockType: string, field: string } | null> | null, featuredImage?: { __typename?: 'ImageObjectType', url: string, width: number, height: number } | null, categories: Array<{ __typename?: 'EventCategory', name: string, slug: string }>, occurrences: Array<{ __typename: 'EventOccurrence', id?: string | null, start: string, end?: string | null, venue?: { __typename: 'VenuePage', id?: string | null, slug: string, title: string } | null }> } & { ' $fragmentName'?: 'EventFragment' };
export type AllEventsQueryVariables = Exact<{ [key: string]: never; }>;
export type AllEventsQuery = { __typename?: 'Query', events: Array<{ __typename?: 'AssociationIndex' } | { __typename?: 'AssociationPage' } | { __typename?: 'EventIndex' } | (
export type AllEventsQuery = { __typename?: 'Query', events: Array<{ __typename?: 'Association' } | { __typename?: 'EventIndex' } | (
{ __typename?: 'EventPage' }
& { ' $fragmentRefs'?: { 'EventFragment': EventFragment } }
) | { __typename?: 'GenericPage' } | { __typename?: 'HomePage' } | { __typename?: 'Page' } | { __typename?: 'VenueIndex' } | { __typename?: 'VenuePage' }>, eventCategories?: Array<{ __typename?: 'EventCategory', name?: string | null, slug?: string | null, showInFilters?: boolean | null } | null> | null };
) | { __typename?: 'GenericPage' } | { __typename?: 'HomePage' } | { __typename?: 'Page' } | { __typename?: 'VenueIndex' } | { __typename?: 'VenuePage' }>, eventCategories?: Array<{ __typename?: 'EventCategory', name: string, slug: string, showInFilters: boolean } | null> | null };
export const GenericFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Generic"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"GenericPage"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"urlPath"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"body"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"blockType"}},{"kind":"Field","name":{"kind":"Name","value":"field"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"RichTextBlock"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"rawValue"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}}]}}]} as unknown as DocumentNode<GenericFragment, unknown>;
export const VenueFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Venue"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"VenuePage"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"body"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"blockType"}},{"kind":"Field","name":{"kind":"Name","value":"field"}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"RichTextBlock"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"rawValue"}},{"kind":"Field","name":{"kind":"Name","value":"value"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"featuredImage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"url"}},{"kind":"Field","name":{"kind":"Name","value":"width"}},{"kind":"Field","name":{"kind":"Name","value":"height"}}]}},{"kind":"Field","name":{"kind":"Name","value":"showAsBookable"}},{"kind":"Field","name":{"kind":"Name","value":"floor"}},{"kind":"Field","name":{"kind":"Name","value":"preposition"}},{"kind":"Field","name":{"kind":"Name","value":"capabilityAudio"}},{"kind":"Field","name":{"kind":"Name","value":"capabilityAudioVideo"}},{"kind":"Field","name":{"kind":"Name","value":"capabilityBar"}},{"kind":"Field","name":{"kind":"Name","value":"capabilityLighting"}},{"kind":"Field","name":{"kind":"Name","value":"capacityLegal"}},{"kind":"Field","name":{"kind":"Name","value":"capacityStanding"}},{"kind":"Field","name":{"kind":"Name","value":"capacitySitting"}}]}}]} as unknown as DocumentNode<VenueFragment, unknown>;

View File

@ -10,11 +10,7 @@ import {
} from "date-fns";
import { toLocalTime, formatDate } from "./date";
import { graphql } from "@/gql";
import {
EventFragment,
EventCategory,
EventOccurrence,
} from "@/gql/graphql";
import { EventFragment, EventCategory, EventOccurrence } from "@/gql/graphql";
export type {
EventFragment,
@ -94,22 +90,14 @@ export const allEventsQuery = graphql(`
export function getSingularEvents(events: EventFragment[]) {
return events
.map((event) => {
return event.occurrences
?.filter((x): x is EventOccurrence => isDefined(x))
.map((occurrence) => {
const eventOccurrence = structuredClone(event);
eventOccurrence.occurrence = occurrence;
return eventOccurrence;
});
return event.occurrences.map((occurrence) => {
const eventOccurrence: any = structuredClone(event);
eventOccurrence.occurrence = occurrence;
return eventOccurrence;
});
})
.flat()
.filter((x): x is SingularEvent => isDefined(x));
.flat();
}
function isDefined<T>(val: T | undefined | null): val is T {
return val !== undefined && val !== null;
}
interface EventsByDate {
[yearMonth: string]: {
[week: string]: {