From d52549f7810bda6289d81ede6471e33e1d93e75b Mon Sep 17 00:00:00 2001 From: thomasgross Date: Wed, 4 Dec 2024 12:52:32 +0100 Subject: [PATCH] feat: add podcast support to WorkPageButtons component --- .../pages/workPageLayout/WorkPageButtons.tsx | 25 ++++++++++++++++--- components/pages/workPageLayout/helper.ts | 5 ++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/components/pages/workPageLayout/WorkPageButtons.tsx b/components/pages/workPageLayout/WorkPageButtons.tsx index 3255b007..4db28661 100644 --- a/components/pages/workPageLayout/WorkPageButtons.tsx +++ b/components/pages/workPageLayout/WorkPageButtons.tsx @@ -7,7 +7,7 @@ import SmartLink from "@/components/shared/smartLink/SmartLink" import { resolveUrl } from "@/lib/helpers/helper.routes" import { useSelectedManifestationStore } from "@/store/selectedManifestation.store" -import { isAudioBook, isEbook } from "./helper" +import { isAudioBook, isEbook, isPodcast } from "./helper" export type WorkPageButtonsProps = { workId: string @@ -41,7 +41,6 @@ const WorkPageButtons = ({ workId }: WorkPageButtonsProps) => { )} - {isAudioBook(selectedManifestation) && ( <> )} + {isPodcast(selectedManifestation) && ( + <> + + + + )} {/* Reader / Player dialog */} {!!selectedManifestation?.identifiers[0].value && ( @@ -64,8 +77,12 @@ const WorkPageButtons = ({ workId }: WorkPageButtonsProps) => { onOpenChange={() => { setIsPlayerOpen(!isPlayerOpen) }} - title="Prøv lydbog" - description="For at låne lydbogen skal du være oprettet som bruger på GO."> + title={`Prøv ${isPodcast(selectedManifestation) ? "Podcast" : "Lydbog"}`} + description={ + isPodcast(selectedManifestation) + ? "For at høre podcast skal du være oprettet som bruger på GO." + : "For at låne lydbogen skal du være oprettet som bruger på GO." + }> )} diff --git a/components/pages/workPageLayout/helper.ts b/components/pages/workPageLayout/helper.ts index 56444660..3c41fd17 100644 --- a/components/pages/workPageLayout/helper.ts +++ b/components/pages/workPageLayout/helper.ts @@ -66,3 +66,8 @@ export const isAudioBook = (manifestation: ManifestationWorkPageFragment | undef if (!manifestation) return false return isOfMaterialType(manifestation, GeneralMaterialTypeCodeEnum.AudioBooks) } + +export const isPodcast = (manifestation: ManifestationWorkPageFragment | undefined | null) => { + if (!manifestation) return false + return isOfMaterialType(manifestation, GeneralMaterialTypeCodeEnum.Podcasts) +}