Skip to content

Commit

Permalink
feat: add podcast support to WorkPageButtons component
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasGross committed Dec 4, 2024
1 parent bee0ecc commit d52549f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
25 changes: 21 additions & 4 deletions components/pages/workPageLayout/WorkPageButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -41,7 +41,6 @@ const WorkPageButtons = ({ workId }: WorkPageButtonsProps) => {
</Button>
</>
)}

{isAudioBook(selectedManifestation) && (
<>
<Button
Expand All @@ -56,6 +55,20 @@ const WorkPageButtons = ({ workId }: WorkPageButtonsProps) => {
</Button>
</>
)}
{isPodcast(selectedManifestation) && (
<>
<Button
ariaLabel="Prøv podcast"
disabled={!!!identifier}
className="mb-grid-gap-half w-full lg:min-w-72 lg:max-w-80"
onClick={() => setIsPlayerOpen(!isPlayerOpen)}>
Prøv podcast
</Button>
<Button ariaLabel="Hør podcast" className="w-full lg:min-w-72 lg:max-w-80">
Not done yet
</Button>
</>
)}

{/* Reader / Player dialog */}
{!!selectedManifestation?.identifiers[0].value && (
Expand All @@ -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."
}>
<Player type="demo" identifier={selectedManifestation.identifiers[0].value} />
</ResponsiveDialog>
)}
Expand Down
5 changes: 5 additions & 0 deletions components/pages/workPageLayout/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit d52549f

Please sign in to comment.