From 5b2d45443f56d3331cb71741bb8f163f814a602e Mon Sep 17 00:00:00 2001 From: DrMint Date: Sun, 6 Mar 2022 00:40:55 +0100 Subject: [PATCH] Groups Metadata type is now a thing, hurray --- src/graphql/operation.graphql | 45 ++- src/graphql/operations-types.ts | 160 ++++++---- src/graphql/operations.ts | 1 - src/graphql/schema.graphql | 520 +++++++++++++++++++++----------- src/pages/library/index.tsx | 25 +- src/queries/helpers.ts | 17 +- 6 files changed, 510 insertions(+), 258 deletions(-) diff --git a/src/graphql/operation.graphql b/src/graphql/operation.graphql index 3f5b07f..77fb0a9 100644 --- a/src/graphql/operation.graphql +++ b/src/graphql/operation.graphql @@ -82,6 +82,7 @@ query getWebsiteInterface($language_code: String) { order_by group_by select_option_sidebar + group } } } @@ -231,7 +232,7 @@ query getLibraryItemsPreview($language_code: String) { } } } - ... on ComponentMetadataOther { + ... on ComponentMetadataGroup { subtype { data { attributes { @@ -244,6 +245,18 @@ query getLibraryItemsPreview($language_code: String) { } } } + subitems_type { + data { + attributes { + slug + titles( + filters: { language: { code: { eq: $language_code } } } + ) { + title + } + } + } + } } } } @@ -409,7 +422,7 @@ query getLibraryItem($slug: String, $language_code: String) { } } } - ... on ComponentMetadataOther { + ... on ComponentMetadataGroup { subtype { data { attributes { @@ -422,6 +435,18 @@ query getLibraryItem($slug: String, $language_code: String) { } } } + subitems_type { + data { + attributes { + slug + titles( + filters: { language: { code: { eq: $language_code } } } + ) { + title + } + } + } + } } } subitem_of { @@ -529,7 +554,7 @@ query getLibraryItem($slug: String, $language_code: String) { } } } - ... on ComponentMetadataOther { + ... on ComponentMetadataGroup { subtype { data { attributes { @@ -544,6 +569,20 @@ query getLibraryItem($slug: String, $language_code: String) { } } } + subitems_type { + data { + attributes { + slug + titles( + filters: { + language: { code: { eq: $language_code } } + } + ) { + title + } + } + } + } } } } diff --git a/src/graphql/operations-types.ts b/src/graphql/operations-types.ts index 603eaeb..87dd152 100644 --- a/src/graphql/operations-types.ts +++ b/src/graphql/operations-types.ts @@ -164,6 +164,7 @@ export type GetWebsiteInterfaceQuery = { order_by: string; group_by: string; select_option_sidebar: string; + group: string; }; }>; }; @@ -291,13 +292,13 @@ export type GetLibraryItemsPreviewQuery = { }; metadata: Array< | { - __typename: "ComponentMetadataBooks"; + __typename: "ComponentMetadataAudio"; subtype: { - __typename: "TextualSubtypeEntityResponse"; + __typename: "AudioSubtypeEntityResponse"; data: { - __typename: "TextualSubtypeEntity"; + __typename: "AudioSubtypeEntity"; attributes: { - __typename: "TextualSubtype"; + __typename: "AudioSubtype"; slug: string; titles: Array<{ __typename: "ComponentTranslationsSimpleTitle"; @@ -308,13 +309,13 @@ export type GetLibraryItemsPreviewQuery = { }; } | { - __typename: "ComponentMetadataVideo"; + __typename: "ComponentMetadataBooks"; subtype: { - __typename: "VideoSubtypeEntityResponse"; + __typename: "TextualSubtypeEntityResponse"; data: { - __typename: "VideoSubtypeEntity"; + __typename: "TextualSubtypeEntity"; attributes: { - __typename: "VideoSubtype"; + __typename: "TextualSubtype"; slug: string; titles: Array<{ __typename: "ComponentTranslationsSimpleTitle"; @@ -339,13 +340,27 @@ export type GetLibraryItemsPreviewQuery = { }; } | { - __typename: "ComponentMetadataAudio"; + __typename: "ComponentMetadataGroup"; subtype: { - __typename: "AudioSubtypeEntityResponse"; + __typename: "GroupSubtypeEntityResponse"; data: { - __typename: "AudioSubtypeEntity"; + __typename: "GroupSubtypeEntity"; attributes: { - __typename: "AudioSubtype"; + __typename: "GroupSubtype"; + slug: string; + titles: Array<{ + __typename: "ComponentTranslationsSimpleTitle"; + title: string; + }>; + }; + }; + }; + subitems_type: { + __typename: "MetadataTypeEntityResponse"; + data: { + __typename: "MetadataTypeEntity"; + attributes: { + __typename: "MetadataType"; slug: string; titles: Array<{ __typename: "ComponentTranslationsSimpleTitle"; @@ -355,14 +370,15 @@ export type GetLibraryItemsPreviewQuery = { }; }; } + | { __typename: "ComponentMetadataOther" } | { - __typename: "ComponentMetadataOther"; + __typename: "ComponentMetadataVideo"; subtype: { - __typename: "OtherSubtypeEntityResponse"; + __typename: "VideoSubtypeEntityResponse"; data: { - __typename: "OtherSubtypeEntity"; + __typename: "VideoSubtypeEntity"; attributes: { - __typename: "OtherSubtype"; + __typename: "VideoSubtype"; slug: string; titles: Array<{ __typename: "ComponentTranslationsSimpleTitle"; @@ -477,6 +493,23 @@ export type GetLibraryItemQuery = { description: string; }>; metadata: Array< + | { + __typename: "ComponentMetadataAudio"; + subtype: { + __typename: "AudioSubtypeEntityResponse"; + data: { + __typename: "AudioSubtypeEntity"; + attributes: { + __typename: "AudioSubtype"; + slug: string; + titles: Array<{ + __typename: "ComponentTranslationsSimpleTitle"; + title: string; + }>; + }; + }; + }; + } | { __typename: "ComponentMetadataBooks"; binding_type: Enum_Componentmetadatabooks_Binding_Type; @@ -508,22 +541,6 @@ export type GetLibraryItemQuery = { }>; }; } - | { - __typename: "ComponentMetadataVideo"; - subtype: { - __typename: "VideoSubtypeEntityResponse"; - data: { - __typename: "VideoSubtypeEntity"; - attributes: { - __typename: "VideoSubtype"; - titles: Array<{ - __typename: "ComponentTranslationsSimpleTitle"; - title: string; - }>; - }; - }; - }; - } | { __typename: "ComponentMetadataGame"; platforms: { @@ -572,13 +589,27 @@ export type GetLibraryItemQuery = { }; } | { - __typename: "ComponentMetadataAudio"; + __typename: "ComponentMetadataGroup"; subtype: { - __typename: "AudioSubtypeEntityResponse"; + __typename: "GroupSubtypeEntityResponse"; data: { - __typename: "AudioSubtypeEntity"; + __typename: "GroupSubtypeEntity"; attributes: { - __typename: "AudioSubtype"; + __typename: "GroupSubtype"; + slug: string; + titles: Array<{ + __typename: "ComponentTranslationsSimpleTitle"; + title: string; + }>; + }; + }; + }; + subitems_type: { + __typename: "MetadataTypeEntityResponse"; + data: { + __typename: "MetadataTypeEntity"; + attributes: { + __typename: "MetadataType"; slug: string; titles: Array<{ __typename: "ComponentTranslationsSimpleTitle"; @@ -588,15 +619,15 @@ export type GetLibraryItemQuery = { }; }; } + | { __typename: "ComponentMetadataOther" } | { - __typename: "ComponentMetadataOther"; + __typename: "ComponentMetadataVideo"; subtype: { - __typename: "OtherSubtypeEntityResponse"; + __typename: "VideoSubtypeEntityResponse"; data: { - __typename: "OtherSubtypeEntity"; + __typename: "VideoSubtypeEntity"; attributes: { - __typename: "OtherSubtype"; - slug: string; + __typename: "VideoSubtype"; titles: Array<{ __typename: "ComponentTranslationsSimpleTitle"; title: string; @@ -668,13 +699,13 @@ export type GetLibraryItemQuery = { }; metadata: Array< | { - __typename: "ComponentMetadataBooks"; + __typename: "ComponentMetadataAudio"; subtype: { - __typename: "TextualSubtypeEntityResponse"; + __typename: "AudioSubtypeEntityResponse"; data: { - __typename: "TextualSubtypeEntity"; + __typename: "AudioSubtypeEntity"; attributes: { - __typename: "TextualSubtype"; + __typename: "AudioSubtype"; slug: string; titles: Array<{ __typename: "ComponentTranslationsSimpleTitle"; @@ -685,13 +716,13 @@ export type GetLibraryItemQuery = { }; } | { - __typename: "ComponentMetadataVideo"; + __typename: "ComponentMetadataBooks"; subtype: { - __typename: "VideoSubtypeEntityResponse"; + __typename: "TextualSubtypeEntityResponse"; data: { - __typename: "VideoSubtypeEntity"; + __typename: "TextualSubtypeEntity"; attributes: { - __typename: "VideoSubtype"; + __typename: "TextualSubtype"; slug: string; titles: Array<{ __typename: "ComponentTranslationsSimpleTitle"; @@ -716,13 +747,27 @@ export type GetLibraryItemQuery = { }; } | { - __typename: "ComponentMetadataAudio"; + __typename: "ComponentMetadataGroup"; subtype: { - __typename: "AudioSubtypeEntityResponse"; + __typename: "GroupSubtypeEntityResponse"; data: { - __typename: "AudioSubtypeEntity"; + __typename: "GroupSubtypeEntity"; attributes: { - __typename: "AudioSubtype"; + __typename: "GroupSubtype"; + slug: string; + titles: Array<{ + __typename: "ComponentTranslationsSimpleTitle"; + title: string; + }>; + }; + }; + }; + subitems_type: { + __typename: "MetadataTypeEntityResponse"; + data: { + __typename: "MetadataTypeEntity"; + attributes: { + __typename: "MetadataType"; slug: string; titles: Array<{ __typename: "ComponentTranslationsSimpleTitle"; @@ -732,14 +777,15 @@ export type GetLibraryItemQuery = { }; }; } + | { __typename: "ComponentMetadataOther" } | { - __typename: "ComponentMetadataOther"; + __typename: "ComponentMetadataVideo"; subtype: { - __typename: "OtherSubtypeEntityResponse"; + __typename: "VideoSubtypeEntityResponse"; data: { - __typename: "OtherSubtypeEntity"; + __typename: "VideoSubtypeEntity"; attributes: { - __typename: "OtherSubtype"; + __typename: "VideoSubtype"; slug: string; titles: Array<{ __typename: "ComponentTranslationsSimpleTitle"; diff --git a/src/graphql/operations.ts b/src/graphql/operations.ts index 4245797..8d52f9a 100644 --- a/src/graphql/operations.ts +++ b/src/graphql/operations.ts @@ -103,7 +103,6 @@ export async function getContentsSlugs( return await graphQL(query, JSON.stringify(variables)); } - export async function getContents( variables: GetContentsQueryVariables ): Promise { diff --git a/src/graphql/schema.graphql b/src/graphql/schema.graphql index 41e523f..526c5af 100644 --- a/src/graphql/schema.graphql +++ b/src/graphql/schema.graphql @@ -509,6 +509,12 @@ type ComponentMetadataGame { ): LanguageRelationResponseCollection } +type ComponentMetadataGroup { + id: ID! + subtype: GroupSubtypeEntityResponse + subitems_type: MetadataTypeEntityResponse +} + type ComponentMetadataMerch { id: ID! merch_item: MerchItemEntityResponse @@ -516,7 +522,6 @@ type ComponentMetadataMerch { type ComponentMetadataOther { id: ID! - subtype: OtherSubtypeEntityResponse } type ComponentMetadataVideo { @@ -1801,6 +1806,46 @@ type GlossaryItemTypeEntityResponseCollection { meta: ResponseCollectionMeta! } +input GroupSubtypeFiltersInput { + id: IDFilterInput + slug: StringFilterInput + createdAt: DateTimeFilterInput + updatedAt: DateTimeFilterInput + and: [GroupSubtypeFiltersInput] + or: [GroupSubtypeFiltersInput] + not: GroupSubtypeFiltersInput +} + +input GroupSubtypeInput { + slug: String + titles: [ComponentTranslationsSimpleTitleInput] +} + +type GroupSubtype { + slug: String! + titles( + filters: ComponentTranslationsSimpleTitleFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): [ComponentTranslationsSimpleTitle] + createdAt: DateTime + updatedAt: DateTime +} + +type GroupSubtypeEntity { + id: ID + attributes: GroupSubtype +} + +type GroupSubtypeEntityResponse { + data: GroupSubtypeEntity +} + +type GroupSubtypeEntityResponseCollection { + data: [GroupSubtypeEntity!]! + meta: ResponseCollectionMeta! +} + input LanguageFiltersInput { id: IDFilterInput name: StringFilterInput @@ -1846,11 +1891,12 @@ type LanguageRelationResponseCollection { } union LibraryItemMetadataDynamicZone = - ComponentMetadataBooks - | ComponentMetadataVideo + ComponentMetadataAudio + | ComponentMetadataBooks | ComponentMetadataGame - | ComponentMetadataAudio + | ComponentMetadataGroup | ComponentMetadataOther + | ComponentMetadataVideo | Error scalar LibraryItemMetadataDynamicZoneInput @@ -2013,6 +2059,46 @@ type MerchItemRelationResponseCollection { data: [MerchItemEntity!]! } +input MetadataTypeFiltersInput { + id: IDFilterInput + slug: StringFilterInput + createdAt: DateTimeFilterInput + updatedAt: DateTimeFilterInput + and: [MetadataTypeFiltersInput] + or: [MetadataTypeFiltersInput] + not: MetadataTypeFiltersInput +} + +input MetadataTypeInput { + slug: String + titles: [ComponentTranslationsSimpleTitleInput] +} + +type MetadataType { + slug: String! + titles( + filters: ComponentTranslationsSimpleTitleFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): [ComponentTranslationsSimpleTitle] + createdAt: DateTime + updatedAt: DateTime +} + +type MetadataTypeEntity { + id: ID + attributes: MetadataType +} + +type MetadataTypeEntityResponse { + data: MetadataTypeEntity +} + +type MetadataTypeEntityResponseCollection { + data: [MetadataTypeEntity!]! + meta: ResponseCollectionMeta! +} + input OtherSubtypeFiltersInput { id: IDFilterInput slug: StringFilterInput @@ -2490,72 +2576,85 @@ type WeaponStoryTypeEntityResponseCollection { input WebsiteInterfaceFiltersInput { id: IDFilterInput - language: LanguageFiltersInput - main_library: StringFilterInput - main_library_description: StringFilterInput - main_news: StringFilterInput - main_merch: StringFilterInput - main_gallery: StringFilterInput - main_archives: StringFilterInput - main_about_us: StringFilterInput - main_licensing: StringFilterInput - main_copyright: StringFilterInput + library: StringFilterInput + contents: StringFilterInput + wiki: StringFilterInput + chronicles: StringFilterInput + library_short_description: StringFilterInput + contents_short_description: StringFilterInput + wiki_short_description: StringFilterInput + chronicles_short_description: StringFilterInput + news: StringFilterInput + merch: StringFilterInput + gallery: StringFilterInput + archives: StringFilterInput + about_us: StringFilterInput + licensing_notice: StringFilterInput + copyright_notice: StringFilterInput + contents_description: StringFilterInput + type: StringFilterInput + category: StringFilterInput + categories: StringFilterInput + size: StringFilterInput + release_date: StringFilterInput + release_year: StringFilterInput + details: StringFilterInput + price: StringFilterInput + width: StringFilterInput + height: StringFilterInput + thickness: StringFilterInput + subitem: StringFilterInput + subitems: StringFilterInput + subitem_of: StringFilterInput + variant: StringFilterInput + variants: StringFilterInput + variant_of: StringFilterInput + summary: StringFilterInput + audio: StringFilterInput + video: StringFilterInput + textual: StringFilterInput + game: StringFilterInput + other: StringFilterInput + return_to: StringFilterInput + left_to_right: StringFilterInput + right_to_left: StringFilterInput + page: StringFilterInput + pages: StringFilterInput + page_order: StringFilterInput + binding: StringFilterInput + type_information: StringFilterInput + front_matter: StringFilterInput + back_matter: StringFilterInput + open_content: StringFilterInput + read_content: StringFilterInput + watch_content: StringFilterInput + listen_content: StringFilterInput + view_scans: StringFilterInput + paperback: StringFilterInput + hardcover: StringFilterInput + ui_language: LanguageFiltersInput + languages: StringFilterInput + select_language: StringFilterInput + language: StringFilterInput library_description: StringFilterInput - library_item_summary: StringFilterInput - library_item_gallery: StringFilterInput - library_item_details: StringFilterInput - library_item_subitems: StringFilterInput - library_item_variants: StringFilterInput - library_item_content: StringFilterInput - global_return_label: StringFilterInput - global_subitem_of: StringFilterInput - global_type: StringFilterInput - global_width: StringFilterInput - global_height: StringFilterInput - global_thickness: StringFilterInput - global_binding: StringFilterInput - global_language: StringFilterInput - global_languages: StringFilterInput - global_page: StringFilterInput - global_pages: StringFilterInput - global_page_order: StringFilterInput - global_release_date: StringFilterInput - global_price: StringFilterInput - library_item_physical_size: StringFilterInput - library_item_type_information: StringFilterInput - library_item_front_matter: StringFilterInput - library_item_back_matter: StringFilterInput - library_item_type_textual: StringFilterInput - library_item_type_audio: StringFilterInput - library_item_type_game: StringFilterInput - library_item_type_video: StringFilterInput - library_item_type_other: StringFilterInput - library_item_open_content: StringFilterInput - library_item_view_scans: StringFilterInput - content_read_content: StringFilterInput - content_watch_content: StringFilterInput - content_listen_content: StringFilterInput - global_category: StringFilterInput - global_categories: StringFilterInput - global_paperback: StringFilterInput - global_hardcover: StringFilterInput - global_left_to_right: StringFilterInput - global_right_to_left: StringFilterInput - main_wiki: StringFilterInput - main_wiki_description: StringFilterInput - main_chronicles: StringFilterInput - main_chronicles_description: StringFilterInput - library_items: StringFilterInput - library_items_description: StringFilterInput - library_content: StringFilterInput - library_content_description: StringFilterInput wiki_description: StringFilterInput - news_description: StringFilterInput chronicles_description: StringFilterInput + news_description: StringFilterInput + merch_description: StringFilterInput gallery_description: StringFilterInput archives_description: StringFilterInput about_us_description: StringFilterInput - merch_description: StringFilterInput + page_not_found: StringFilterInput + default_description: StringFilterInput + name: StringFilterInput + show_subitems: StringFilterInput + show_primary_items: StringFilterInput + show_secondary_items: StringFilterInput + no_type: StringFilterInput + no_year: StringFilterInput + order_by: StringFilterInput + group_by: StringFilterInput + select_option_sidebar: StringFilterInput createdAt: DateTimeFilterInput updatedAt: DateTimeFilterInput and: [WebsiteInterfaceFiltersInput] @@ -2564,141 +2663,167 @@ input WebsiteInterfaceFiltersInput { } input WebsiteInterfaceInput { - language: ID - main_library: String - main_library_description: String - main_news: String - main_merch: String - main_gallery: String - main_archives: String - main_about_us: String - main_licensing: String - main_copyright: String + library: String + contents: String + wiki: String + chronicles: String + library_short_description: String + contents_short_description: String + wiki_short_description: String + chronicles_short_description: String + news: String + merch: String + gallery: String + archives: String + about_us: String + licensing_notice: String + copyright_notice: String + contents_description: String + type: String + category: String + categories: String + size: String + release_date: String + release_year: String + details: String + price: String + width: String + height: String + thickness: String + subitem: String + subitems: String + subitem_of: String + variant: String + variants: String + variant_of: String + summary: String + audio: String + video: String + textual: String + game: String + other: String + return_to: String + left_to_right: String + right_to_left: String + page: String + pages: String + page_order: String + binding: String + type_information: String + front_matter: String + back_matter: String + open_content: String + read_content: String + watch_content: String + listen_content: String + view_scans: String + paperback: String + hardcover: String + ui_language: ID + languages: String + select_language: String + language: String library_description: String - library_item_summary: String - library_item_gallery: String - library_item_details: String - library_item_subitems: String - library_item_variants: String - library_item_content: String - global_return_label: String - global_subitem_of: String - global_type: String - global_width: String - global_height: String - global_thickness: String - global_binding: String - global_language: String - global_languages: String - global_page: String - global_pages: String - global_page_order: String - global_release_date: String - global_price: String - library_item_physical_size: String - library_item_type_information: String - library_item_front_matter: String - library_item_back_matter: String - library_item_type_textual: String - library_item_type_audio: String - library_item_type_game: String - library_item_type_video: String - library_item_type_other: String - library_item_open_content: String - library_item_view_scans: String - content_read_content: String - content_watch_content: String - content_listen_content: String - global_category: String - global_categories: String - global_paperback: String - global_hardcover: String - global_left_to_right: String - global_right_to_left: String - main_wiki: String - main_wiki_description: String - main_chronicles: String - main_chronicles_description: String - library_items: String - library_items_description: String - library_content: String - library_content_description: String wiki_description: String - news_description: String chronicles_description: String + news_description: String + merch_description: String gallery_description: String archives_description: String about_us_description: String - merch_description: String + page_not_found: String + default_description: String + name: String + show_subitems: String + show_primary_items: String + show_secondary_items: String + no_type: String + no_year: String + order_by: String + group_by: String + select_option_sidebar: String } type WebsiteInterface { - language: LanguageEntityResponse - main_library: String - main_library_description: String - main_news: String - main_merch: String - main_gallery: String - main_archives: String - main_about_us: String - main_licensing: String - main_copyright: String + library: String + contents: String + wiki: String + chronicles: String + library_short_description: String + contents_short_description: String + wiki_short_description: String + chronicles_short_description: String + news: String + merch: String + gallery: String + archives: String + about_us: String + licensing_notice: String + copyright_notice: String + contents_description: String + type: String + category: String + categories: String + size: String + release_date: String + release_year: String + details: String + price: String + width: String + height: String + thickness: String + subitem: String + subitems: String + subitem_of: String + variant: String + variants: String + variant_of: String + summary: String + audio: String + video: String + textual: String + game: String + other: String + return_to: String + left_to_right: String + right_to_left: String + page: String + pages: String + page_order: String + binding: String + type_information: String + front_matter: String + back_matter: String + open_content: String + read_content: String + watch_content: String + listen_content: String + view_scans: String + paperback: String + hardcover: String + ui_language: LanguageEntityResponse + languages: String + select_language: String + language: String library_description: String - library_item_summary: String - library_item_gallery: String - library_item_details: String - library_item_subitems: String - library_item_variants: String - library_item_content: String - global_return_label: String - global_subitem_of: String - global_type: String - global_width: String - global_height: String - global_thickness: String - global_binding: String - global_language: String - global_languages: String - global_page: String - global_pages: String - global_page_order: String - global_release_date: String - global_price: String - library_item_physical_size: String - library_item_type_information: String - library_item_front_matter: String - library_item_back_matter: String - library_item_type_textual: String - library_item_type_audio: String - library_item_type_game: String - library_item_type_video: String - library_item_type_other: String - library_item_open_content: String - library_item_view_scans: String - content_read_content: String - content_watch_content: String - content_listen_content: String - global_category: String - global_categories: String - global_paperback: String - global_hardcover: String - global_left_to_right: String - global_right_to_left: String - main_wiki: String - main_wiki_description: String - main_chronicles: String - main_chronicles_description: String - library_items: String - library_items_description: String - library_content: String - library_content_description: String wiki_description: String - news_description: String chronicles_description: String + news_description: String + merch_description: String gallery_description: String archives_description: String about_us_description: String - merch_description: String + page_not_found: String + default_description: String + name: String + show_subitems: String + show_primary_items: String + show_secondary_items: String + no_type: String + no_year: String + order_by: String + group_by: String + select_option_sidebar: String createdAt: DateTime updatedAt: DateTime } @@ -2819,6 +2944,7 @@ union GenericMorph = | ComponentMetadataAudio | ComponentMetadataBooks | ComponentMetadataGame + | ComponentMetadataGroup | ComponentMetadataMerch | ComponentMetadataOther | ComponentMetadataVideo @@ -2866,9 +2992,11 @@ union GenericMorph = | GamePlatform | GlossaryItem | GlossaryItemType + | GroupSubtype | Language | LibraryItem | MerchItem + | MetadataType | OtherSubtype | Post | RangedContent @@ -2963,6 +3091,12 @@ type Query { pagination: PaginationArg = {} sort: [String] = [] ): GlossaryItemTypeEntityResponseCollection + groupSubtype(id: ID): GroupSubtypeEntityResponse + groupSubtypes( + filters: GroupSubtypeFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): GroupSubtypeEntityResponseCollection language(id: ID): LanguageEntityResponse languages( filters: LanguageFiltersInput @@ -2981,6 +3115,12 @@ type Query { pagination: PaginationArg = {} sort: [String] = [] ): MerchItemEntityResponseCollection + metadataType(id: ID): MetadataTypeEntityResponse + metadataTypes( + filters: MetadataTypeFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): MetadataTypeEntityResponseCollection otherSubtype(id: ID): OtherSubtypeEntityResponse otherSubtypes( filters: OtherSubtypeFiltersInput @@ -3116,6 +3256,12 @@ type Mutation { data: GlossaryItemTypeInput! ): GlossaryItemTypeEntityResponse deleteGlossaryItemType(id: ID!): GlossaryItemTypeEntityResponse + createGroupSubtype(data: GroupSubtypeInput!): GroupSubtypeEntityResponse + updateGroupSubtype( + id: ID! + data: GroupSubtypeInput! + ): GroupSubtypeEntityResponse + deleteGroupSubtype(id: ID!): GroupSubtypeEntityResponse createLanguage(data: LanguageInput!): LanguageEntityResponse updateLanguage(id: ID!, data: LanguageInput!): LanguageEntityResponse deleteLanguage(id: ID!): LanguageEntityResponse @@ -3125,6 +3271,12 @@ type Mutation { createMerchItem(data: MerchItemInput!): MerchItemEntityResponse updateMerchItem(id: ID!, data: MerchItemInput!): MerchItemEntityResponse deleteMerchItem(id: ID!): MerchItemEntityResponse + createMetadataType(data: MetadataTypeInput!): MetadataTypeEntityResponse + updateMetadataType( + id: ID! + data: MetadataTypeInput! + ): MetadataTypeEntityResponse + deleteMetadataType(id: ID!): MetadataTypeEntityResponse createOtherSubtype(data: OtherSubtypeInput!): OtherSubtypeEntityResponse updateOtherSubtype( id: ID! diff --git a/src/pages/library/index.tsx b/src/pages/library/index.tsx index 1c511aa..c3ff027 100644 --- a/src/pages/library/index.tsx +++ b/src/pages/library/index.tsx @@ -191,6 +191,7 @@ function getGroups( groupType.set(langui.textual, []); groupType.set(langui.video, []); groupType.set(langui.other, []); + groupType.set(langui.group, []); groupType.set(langui.no_type, []); items.map((item) => { if (item.attributes.metadata.length > 0) { @@ -208,26 +209,28 @@ function getGroups( groupType.get(langui.video)?.push(item); break; case "ComponentMetadataOther": + groupType.get(langui.other)?.push(item); + break; + case "ComponentMetadataGroup": switch ( - item.attributes.metadata[0].subtype.data.attributes.slug + item.attributes.metadata[0].subitems_type.data.attributes.slug ) { - case "audio-case": + case "audio": groupType.get(langui.audio)?.push(item); break; - - case "video-case": + case "video": groupType.get(langui.video)?.push(item); break; - - case "game-case": + case "game": groupType.get(langui.game)?.push(item); break; - - default: - groupType.get(langui.other)?.push(item); + case "textual": + groupType.get(langui.textual)?.push(item); + break; + case "mixed": + groupType.get(langui.group)?.push(item); break; } - break; } } else { @@ -280,7 +283,7 @@ function filterItems( if ( showSubitems && item.attributes.metadata.length > 0 && - item.attributes.metadata[0].__typename === "ComponentMetadataOther" && + item.attributes.metadata[0].__typename === "ComponentMetadataGroup" && (item.attributes.metadata[0].subtype.data.attributes.slug === "variant-set" || item.attributes.metadata[0].subtype.data.attributes.slug === diff --git a/src/queries/helpers.ts b/src/queries/helpers.ts index acaf0a7..6d9c5b5 100644 --- a/src/queries/helpers.ts +++ b/src/queries/helpers.ts @@ -71,6 +71,8 @@ export function prettyItemType( return langui.game; case "ComponentMetadataVideo": return langui.video; + case "ComponentMetadataGroup": + return langui.group; case "ComponentMetadataOther": return langui.other; default: @@ -82,21 +84,32 @@ export function prettyItemSubType(metadata: { __typename: GetLibraryItemsPreviewQuery["libraryItems"]["data"][number]["attributes"]["metadata"][number]["__typename"]; subtype?: any; platforms?: any; + subitems_type?: any; }): string { switch (metadata.__typename) { case "ComponentMetadataAudio": case "ComponentMetadataBooks": case "ComponentMetadataVideo": - case "ComponentMetadataOther": { return metadata.subtype.data.attributes.titles.length > 0 ? metadata.subtype.data.attributes.titles[0].title : prettySlug(metadata.subtype.data.attributes.slug); - } case "ComponentMetadataGame": return metadata.platforms.data.length > 0 ? metadata.platforms.data[0].attributes.short : ""; + case "ComponentMetadataGroup": { + const firstPart = + metadata.subtype.data.attributes.titles.length > 0 + ? metadata.subtype.data.attributes.titles[0].title + : prettySlug(metadata.subtype.data.attributes.slug); + + const secondPart = + metadata.subitems_type.data.attributes.titles.length > 0 + ? metadata.subitems_type.data.attributes.titles[0].title + : prettySlug(metadata.subitems_type.data.attributes.slug); + return `${secondPart} ${firstPart})`; + } default: return ""; }