From e1cd5424f78d2468db19099da722a24ec3d7ecb1 Mon Sep 17 00:00:00 2001 From: DrMint Date: Thu, 2 Jun 2022 22:00:27 +0200 Subject: [PATCH] Added link from content to corresponding library items --- src/components/Markdown/Markdawn.tsx | 2 +- src/graphql/operations/getContentText.graphql | 109 +++++++++++++++++- src/pages/contents/[slug]/index.tsx | 74 +++++++++++- 3 files changed, 181 insertions(+), 4 deletions(-) diff --git a/src/components/Markdown/Markdawn.tsx b/src/components/Markdown/Markdawn.tsx index 873370b..6fe896a 100644 --- a/src/components/Markdown/Markdawn.tsx +++ b/src/components/Markdown/Markdawn.tsx @@ -231,7 +231,7 @@ export function Markdawn(props: Immutable): JSX.Element { component: (compProps: { children: React.ReactNode }) => ( <> -
{compProps.children}
+
{compProps.children}
), }, diff --git a/src/graphql/operations/getContentText.graphql b/src/graphql/operations/getContentText.graphql index 47effbf..5b186c5 100644 --- a/src/graphql/operations/getContentText.graphql +++ b/src/graphql/operations/getContentText.graphql @@ -34,10 +34,11 @@ query getContentText($slug: String, $language_code: String) { } library_item { data { + id attributes { - slug title subtitle + slug thumbnail { data { attributes { @@ -45,6 +46,112 @@ query getContentText($slug: String, $language_code: String) { } } } + release_date { + ...datePicker + } + price { + ...pricePicker + } + categories { + data { + id + attributes { + name + short + } + } + } + metadata { + __typename + ... on ComponentMetadataBooks { + subtype { + data { + attributes { + slug + titles( + filters: { + language: { code: { eq: $language_code } } + } + ) { + title + } + } + } + } + } + ... on ComponentMetadataGame { + platforms { + data { + id + attributes { + short + } + } + } + } + ... on ComponentMetadataVideo { + subtype { + data { + attributes { + slug + titles( + filters: { + language: { code: { eq: $language_code } } + } + ) { + title + } + } + } + } + } + ... on ComponentMetadataAudio { + subtype { + data { + attributes { + slug + titles( + filters: { + language: { code: { eq: $language_code } } + } + ) { + title + } + } + } + } + } + ... on ComponentMetadataGroup { + subtype { + data { + attributes { + slug + titles( + filters: { + language: { code: { eq: $language_code } } + } + ) { + title + } + } + } + } + subitems_type { + data { + attributes { + slug + titles( + filters: { + language: { code: { eq: $language_code } } + } + ) { + title + } + } + } + } + } + } } } } diff --git a/src/pages/contents/[slug]/index.tsx b/src/pages/contents/[slug]/index.tsx index e0fabca..cb5c02d 100644 --- a/src/pages/contents/[slug]/index.tsx +++ b/src/pages/contents/[slug]/index.tsx @@ -1,6 +1,7 @@ import { AppLayout } from "components/AppLayout"; import { Chip } from "components/Chip"; import { HorizontalLine } from "components/HorizontalLine"; +import { PreviewCardCTAs } from "components/Library/PreviewCardCTAs"; import { Markdawn } from "components/Markdown/Markdawn"; import { TOC } from "components/Markdown/TOC"; import { @@ -9,7 +10,8 @@ import { } from "components/PanelComponents/ReturnButton"; import { ContentPanel } from "components/Panels/ContentPanel"; import { SubPanel } from "components/Panels/SubPanel"; -import { PreviewLine, TranslatedPreviewLine } from "components/PreviewLine"; +import { PreviewCard } from "components/PreviewCard"; +import { TranslatedPreviewLine } from "components/PreviewLine"; import { RecorderChip } from "components/RecorderChip"; import { ThumbnailHeader } from "components/ThumbnailHeader"; import { ToolTip } from "components/ToolTip"; @@ -19,8 +21,10 @@ import { getNextContent, getPreviousContent } from "helpers/contents"; import { prettyinlineTitle, prettyLanguage, + prettyItemSubType, prettySlug, } from "helpers/formatters"; +import { isUntangibleGroupItem } from "helpers/libraryItem"; import { getStatusDescription } from "helpers/others"; import { ContentWithTranslations, Immutable } from "helpers/types"; import { useMediaMobile } from "hooks/useMediaQuery"; @@ -38,7 +42,7 @@ interface Props extends AppStaticProps { } export default function Content(props: Immutable): JSX.Element { - const { langui, content, languages } = props; + const { langui, content, languages, currencies } = props; const isMobile = useMediaMobile(); const [selectedTranslation, LanguageSwitcher] = useSmartLanguage({ @@ -184,6 +188,72 @@ export default function Content(props: Immutable): JSX.Element { )} + {content.ranged_contents?.data && + content.ranged_contents.data.length > 0 && ( + <> + +
+ {/* TODO: Add to langui */} +

Source

+
+ {content.ranged_contents.data.map((rangedContent) => { + const libraryItem = + rangedContent.attributes?.library_item?.data; + if (libraryItem?.attributes && libraryItem.id) { + return ( +
+ 0 && + libraryItem.attributes.metadata[0] + ? [ + prettyItemSubType( + libraryItem.attributes.metadata[0] + ), + ] + : [] + } + bottomChips={libraryItem.attributes.categories?.data.map( + (category) => category.attributes?.short ?? "" + )} + metadata={{ + currencies: currencies, + release_date: libraryItem.attributes.release_date, + price: libraryItem.attributes.price, + position: "Bottom", + }} + infoAppend={ + + } + /> +
+ ); + } + return <>; + })} +
+
+ + )} + {selectedTranslation?.text_set?.text && ( <>