diff --git a/src/graphql/operation.graphql b/src/graphql/operation.graphql index 30d6374..dc6b638 100644 --- a/src/graphql/operation.graphql +++ b/src/graphql/operation.graphql @@ -252,6 +252,24 @@ query getLibraryItem($slug: String, $language_code: String) { } } } + ... on ComponentMetadataMerch { + merch_item { + data { + attributes { + slug + } + } + } + } + ... on ComponentMetadataOther { + subtype { + data { + attributes { + slug + } + } + } + } } subitem_of { data { @@ -326,7 +344,9 @@ query getLibraryItem($slug: String, $language_code: String) { titles( filters: { language: { code: { eq: $language_code } } } ) { + pre_title title + subtitle } text_set { id diff --git a/src/graphql/operations-types.ts b/src/graphql/operations-types.ts index a2f0113..c9d1675 100644 --- a/src/graphql/operations-types.ts +++ b/src/graphql/operations-types.ts @@ -50,10 +50,10 @@ export enum Enum_Componentmetadatavideo_Resolution { } export enum Enum_Componenttranslationschronologyitem_Status { - Incomplete = 'Incomplete', - Draft = 'Draft', - Review = 'Review', - Done = 'Done' + Incomplete = "Incomplete", + Draft = "Draft", + Review = "Review", + Done = "Done", } // __________________________________________________________________ @@ -397,6 +397,32 @@ export type GetLibraryItemQuery = { }>; }; } + | { + __typename: "ComponentMetadataMerch"; + merch_item: { + __typename: "MerchItemEntityResponse"; + data: { + __typename: "MerchItemEntity"; + attributes: { + __typename: "MerchItem"; + slug: string; + }; + }; + }; + } + | { + __typename: "ComponentMetadataOther"; + subtype: { + __typename: "OtherSubtypeEntityResponse"; + data: { + __typename: "OtherSubtypeEntity"; + attributes: { + __typename: "OtherSubtype"; + slug: string; + }; + }; + }; + } | { __typename: "Error" } >; subitem_of: { @@ -496,7 +522,9 @@ export type GetLibraryItemQuery = { }; titles: Array<{ __typename: "ComponentTranslationsTitle"; + pre_title: string; title: string; + subtitle: string; }>; text_set: Array<{ __typename: "ComponentSetsTextSet"; diff --git a/src/graphql/schema.graphql b/src/graphql/schema.graphql index 2ece10c..e8050d3 100644 --- a/src/graphql/schema.graphql +++ b/src/graphql/schema.graphql @@ -482,6 +482,16 @@ type ComponentMetadataGame { ): LanguageRelationResponseCollection } +type ComponentMetadataMerch { + id: ID! + merch_item: MerchItemEntityResponse +} + +type ComponentMetadataOther { + id: ID! + subtype: OtherSubtypeEntityResponse +} + enum ENUM_COMPONENTMETADATAVIDEO_RESOLUTION { SD_480p HD_720p @@ -1398,6 +1408,7 @@ input ContentInput { text_set: [ComponentSetsTextSetInput] video_set: [ComponentSetsVideoSetInput] audio_set: [ComponentSetsAudioSetInput] + thumbnail: ID } type Content { @@ -1433,6 +1444,7 @@ type Content { pagination: PaginationArg = {} sort: [String] = [] ): [ComponentSetsAudioSet] + thumbnail: UploadFileEntityResponse createdAt: DateTime updatedAt: DateTime } @@ -1693,6 +1705,8 @@ union LibraryItemMetadataDynamicZone = | ComponentMetadataVideo | ComponentMetadataGame | ComponentMetadataAudio + | ComponentMetadataMerch + | ComponentMetadataOther | Error scalar LibraryItemMetadataDynamicZoneInput @@ -1830,6 +1844,74 @@ type LibraryVariantEntityResponseCollection { meta: ResponseCollectionMeta! } +input MerchItemFiltersInput { + id: IDFilterInput + slug: StringFilterInput + createdAt: DateTimeFilterInput + updatedAt: DateTimeFilterInput + and: [MerchItemFiltersInput] + or: [MerchItemFiltersInput] + not: MerchItemFiltersInput +} + +input MerchItemInput { + slug: String +} + +type MerchItem { + slug: String! + createdAt: DateTime + updatedAt: DateTime +} + +type MerchItemEntity { + id: ID + attributes: MerchItem +} + +type MerchItemEntityResponse { + data: MerchItemEntity +} + +type MerchItemEntityResponseCollection { + data: [MerchItemEntity!]! + meta: ResponseCollectionMeta! +} + +input OtherSubtypeFiltersInput { + id: IDFilterInput + slug: StringFilterInput + createdAt: DateTimeFilterInput + updatedAt: DateTimeFilterInput + and: [OtherSubtypeFiltersInput] + or: [OtherSubtypeFiltersInput] + not: OtherSubtypeFiltersInput +} + +input OtherSubtypeInput { + slug: String +} + +type OtherSubtype { + slug: String! + createdAt: DateTime + updatedAt: DateTime +} + +type OtherSubtypeEntity { + id: ID + attributes: OtherSubtype +} + +type OtherSubtypeEntityResponse { + data: OtherSubtypeEntity +} + +type OtherSubtypeEntityResponseCollection { + data: [OtherSubtypeEntity!]! + meta: ResponseCollectionMeta! +} + input PostFiltersInput { id: IDFilterInput authors: RecorderFiltersInput @@ -2225,6 +2307,8 @@ union GenericMorph = | ComponentMetadataAudio | ComponentMetadataBooks | ComponentMetadataGame + | ComponentMetadataMerch + | ComponentMetadataOther | ComponentMetadataVideo | ComponentPageBuilderComponentPane | ComponentPageBuilderComponentTab @@ -2270,6 +2354,8 @@ union GenericMorph = | Language | LibraryItem | LibraryVariant + | MerchItem + | OtherSubtype | Post | RangedContent | Recorder @@ -2377,6 +2463,18 @@ type Query { pagination: PaginationArg = {} sort: [String] = [] ): LibraryVariantEntityResponseCollection + merchItem(id: ID): MerchItemEntityResponse + merchItems( + filters: MerchItemFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): MerchItemEntityResponseCollection + otherSubtype(id: ID): OtherSubtypeEntityResponse + otherSubtypes( + filters: OtherSubtypeFiltersInput + pagination: PaginationArg = {} + sort: [String] = [] + ): OtherSubtypeEntityResponseCollection post(id: ID): PostEntityResponse posts( filters: PostFiltersInput @@ -2494,6 +2592,15 @@ type Mutation { data: LibraryVariantInput! ): LibraryVariantEntityResponse deleteLibraryVariant(id: ID!): LibraryVariantEntityResponse + createMerchItem(data: MerchItemInput!): MerchItemEntityResponse + updateMerchItem(id: ID!, data: MerchItemInput!): MerchItemEntityResponse + deleteMerchItem(id: ID!): MerchItemEntityResponse + createOtherSubtype(data: OtherSubtypeInput!): OtherSubtypeEntityResponse + updateOtherSubtype( + id: ID! + data: OtherSubtypeInput! + ): OtherSubtypeEntityResponse + deleteOtherSubtype(id: ID!): OtherSubtypeEntityResponse createPost(data: PostInput!): PostEntityResponse updatePost(id: ID!, data: PostInput!): PostEntityResponse deletePost(id: ID!): PostEntityResponse diff --git a/src/pages/library/[slug].tsx b/src/pages/library/[slug].tsx index e6bf5d2..af683f2 100644 --- a/src/pages/library/[slug].tsx +++ b/src/pages/library/[slug].tsx @@ -11,6 +11,7 @@ import { convertMmToInch, getAssetURL, prettyDate, + prettyinlineTitle, prettyPrice, prettySlug, } from "queries/helpers"; @@ -102,10 +103,11 @@ export default function Library(props: Props): JSX.Element { ) : ( @@ -237,7 +239,7 @@ export default function Library(props: Props): JSX.Element {

Type:

- {capitalizeString( + {prettySlug( item.metadata[0].subtype.data.attributes.slug )} @@ -255,7 +257,7 @@ export default function Library(props: Props): JSX.Element {

Page order:

-

{item.metadata[0].page_order}

+

{prettySlug(item.metadata[0].page_order)}

@@ -267,6 +269,30 @@ export default function Library(props: Props): JSX.Element { ))}
+ ) : item.metadata[0].__typename === + "ComponentMetadataAudio" ? ( + <> + ) : item.metadata[0].__typename === + "ComponentMetadataVideo" ? ( + <> + ) : item.metadata[0].__typename === + "ComponentMetadataGame" ? ( + <> + ) : item.metadata[0].__typename === + "ComponentMetadataMerch" ? ( + <> + ) : item.metadata[0].__typename === + "ComponentMetadataOther" ? ( + <> +
+

Type:

+ + {prettySlug( + item.metadata[0].subtype.data.attributes.slug + )} + +
+ ) : ( "" )} @@ -279,9 +305,9 @@ export default function Library(props: Props): JSX.Element {
{item.subitems.data.length > 0 ? ( -
+

Subitems

-
+
{item.subitems.data.map((subitem) => ( ))} @@ -304,9 +330,17 @@ export default function Library(props: Props): JSX.Element {

- {content.attributes.content.data - ? content.attributes.content.data.attributes - .titles[0].title + {content.attributes.content.data && + content.attributes.content.data.attributes.titles + .length > 0 + ? prettyinlineTitle( + content.attributes.content.data.attributes + .titles[0].pre_title, + content.attributes.content.data.attributes + .titles[0].title, + content.attributes.content.data.attributes + .titles[0].subtitle + ) : prettySlug(content.attributes.slug, item.slug)}

@@ -328,10 +362,10 @@ export default function Library(props: Props): JSX.Element {

{content.attributes.content.data ? ( - { + {prettySlug( content.attributes.content.data.attributes.type.data .attributes.slug - } + )} ) : ( "" diff --git a/src/queries/helpers.ts b/src/queries/helpers.ts index ae9df52..f493a7f 100644 --- a/src/queries/helpers.ts +++ b/src/queries/helpers.ts @@ -31,10 +31,20 @@ export function prettyPrice( export function prettySlug(slug: string, parentSlug?: string): string { if (parentSlug && slug.startsWith(parentSlug)) slug = slug.substring(parentSlug.length + 1); - return capitalizeString(slug.replace(new RegExp("-", 'g'), " ")) - return slug; + slug = slug.replace(new RegExp("-", 'g'), " "); + slug = slug.replace(new RegExp("_", 'g'), " "); + return capitalizeString(slug) } +export function prettyinlineTitle(pretitle:string, title: string, subtitle:string): string { + let result = ""; + if (pretitle) result += pretitle + ": " + result += title; + if (subtitle) result += " - " + subtitle; + return result; +} + + export function capitalizeString(string:string):string { function capitalizeWord(word: string): string { return word.charAt(0).toUpperCase() + word.substring(1);