Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAY-2725] Add purchase button to mobile web albums #8206

Merged
merged 3 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions packages/web/src/components/collection/mobile/CollectionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { FeatureFlags } from '@audius/common/services'
import {
CommonState,
OverflowAction,
PurchaseableContentType,
cacheCollectionsSelectors,
useEditPlaylistModal
} from '@audius/common/store'
import {
Box,
Button,
ButtonProps,
Flex,
Expand All @@ -24,6 +26,7 @@ import DynamicImage from 'components/dynamic-image/DynamicImage'
import { UserLink } from 'components/link'
import Skeleton from 'components/skeleton/Skeleton'
import { StaticImage } from 'components/static-image/StaticImage'
import { GatedContentSection } from 'components/track/GatedContentSection'
import { UserGeneratedText } from 'components/user-generated-text'
import { useCollectionCoverArt } from 'hooks/useCollectionCoverArt'
import { useFlag } from 'hooks/useRemoteConfig'
Expand Down Expand Up @@ -97,6 +100,9 @@ const CollectionHeader = ({
lastModifiedDate,
numTracks,
isPlayable,
isStreamGated,
streamConditions,
access,
duration,
isPublished = false,
isPublishing = false,
Expand All @@ -119,6 +125,9 @@ const CollectionHeader = ({
}: MobileCollectionHeaderProps) => {
const { isSsrEnabled } = useSsrContext()
const { isEnabled: isEditAlbumsEnabled } = useFlag(FeatureFlags.EDIT_ALBUMS)
const { isEnabled: isPremiumAlbumsEnabled } = useFlag(
FeatureFlags.PREMIUM_ALBUMS_ENABLED
)
const collection = useSelector((state: CommonState) =>
getCollection(state, { id: collectionId })
) as Collection
Expand Down Expand Up @@ -236,6 +245,26 @@ const CollectionHeader = ({
{isPlayable ? (
<PlayButton playing={playing} onPlay={onPlay} fullWidth />
) : null}
{isPremiumAlbumsEnabled &&
isAlbum &&
streamConditions &&
collectionId ? (
<Box mb='xl' w='100%'>
<GatedContentSection
isLoading={isLoading}
contentId={collectionId}
contentType={PurchaseableContentType.ALBUM}
streamConditions={streamConditions}
hasStreamAccess={!!access?.stream}
isOwner={isOwner}
wrapperClassName={styles.gatedContentSectionWrapper}
className={styles.gatedContentSection}
buttonClassName={styles.gatedContentSectionButton}
ownerId={userId}
/>
</Box>
) : null}

<ActionButtonRow
isOwner={isOwner}
isSaved={isSaved}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/components/track/GatedContentSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ const UnlockedGatedContentSection = ({
</span>
</div>
) : (
<Flex direction='row'>
<Flex direction='row' wrap='wrap'>
<span>{messages.purchased}&nbsp;</span>
{trackOwner ? (
<>
Expand Down