Skip to content

Commit 7243c38

Browse files
authored
[PE-6024] Use real remix eventData in remix contest section (#11916)
1 parent 6150ac7 commit 7243c38

File tree

5 files changed

+46
-139
lines changed

5 files changed

+46
-139
lines changed

packages/common/src/api/tan-query/events/useRemixContest.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { EventEntityTypeEnum, EventEventTypeEnum } from '@audius/sdk'
2+
import type { OverrideProperties } from 'type-fest'
23

34
import { Event } from '~/models/Event'
45
import { ID } from '~/models/Identifiers'
@@ -8,13 +9,25 @@ import { SelectableQueryOptions } from '../types'
89
import { useEvent } from './useEvent'
910
import { useEventIdsByEntityId } from './useEventsByEntityId'
1011

12+
type RemixContestData = {
13+
description: string
14+
prizeInfo: string
15+
}
16+
17+
type RemixContestEvent = OverrideProperties<
18+
Event,
19+
{
20+
eventData: RemixContestData
21+
}
22+
>
23+
1124
/**
1225
* Hook to fetch the remix contest event for a given entity ID.
1326
* Returns the first active RemixContest event found, or null if none exists.
1427
*/
1528
export const useRemixContest = (
1629
entityId: ID | null | undefined,
17-
options?: SelectableQueryOptions<Event>
30+
options?: SelectableQueryOptions<Event, RemixContestEvent>
1831
) => {
1932
const eventsQuery = useEventIdsByEntityId(
2033
{
@@ -27,7 +40,10 @@ export const useRemixContest = (
2740

2841
const remixContestId = eventsQuery.data?.[0]
2942

30-
const { data: remixContest } = useEvent(remixContestId, options)
43+
const { data: remixContest } = useEvent<RemixContestEvent>(
44+
remixContestId,
45+
options
46+
)
3147

3248
return {
3349
...eventsQuery,

packages/mobile/src/screens/track-screen/TrackScreenDetailsTile.tsx

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import type {
2626
Track,
2727
User
2828
} from '@audius/common/models'
29-
import { FeatureFlags } from '@audius/common/services'
3029
import type { CommonState } from '@audius/common/store'
3130
import {
3231
accountSelectors,
@@ -59,7 +58,6 @@ import {
5958
Divider,
6059
Flex,
6160
IconCalendarMonth,
62-
IconCloudUpload,
6361
IconPause,
6462
IconPlay,
6563
IconRepeatOff,
@@ -87,7 +85,6 @@ import { OfflineStatusRow } from 'app/components/offline-downloads'
8785
import { TrackDogEar } from 'app/components/track/TrackDogEar'
8886
import UserBadges from 'app/components/user-badges'
8987
import { useNavigation } from 'app/hooks/useNavigation'
90-
import { useFeatureFlag } from 'app/hooks/useRemoteConfig'
9188
import { make, track as trackEvent } from 'app/services/analytics'
9289
import { makeStyles } from 'app/styles'
9390

@@ -236,11 +233,8 @@ export const TrackScreenDetailsTile = ({
236233
track?.genre === Genre.PODCASTS || track?.genre === Genre.AUDIOBOOKS
237234
const aiAttributionUserId = track?.ai_attribution_user_id
238235
const isUSDCPurchaseGated = isContentUSDCPurchaseGated(streamConditions)
239-
const { isEnabled: isRemixContestEnabled } = useFeatureFlag(
240-
FeatureFlags.REMIX_CONTEST
241-
)
242236
const { data: remixContest } = useRemixContest(trackId)
243-
const isRemixContest = isRemixContestEnabled && remixContest
237+
const isRemixContest = !!remixContest
244238

245239
const isPlayingPreview = isPreviewing && isPlaying
246240
const isPlayingFullAccess = isPlaying && !isPreviewing
@@ -446,9 +440,7 @@ export const TrackScreenDetailsTile = ({
446440
const addToAlbumAction =
447441
isOwner && !ddexApp ? OverflowAction.ADD_TO_ALBUM : null
448442
const overflowActions = [
449-
isOwner && isRemixContestEnabled && !isRemix
450-
? OverflowAction.HOST_REMIX_CONTEST
451-
: null,
443+
isOwner && !isRemix ? OverflowAction.HOST_REMIX_CONTEST : null,
452444
addToAlbumAction,
453445
!isUnlisted || isOwner ? OverflowAction.ADD_TO_PLAYLIST : null,
454446
isOwner
@@ -502,46 +494,6 @@ export const TrackScreenDetailsTile = ({
502494
publish
503495
])
504496

505-
const handlePressSubmitRemix = useCallback(() => {
506-
if (!track?.track_id) return
507-
navigation.push('Upload', {
508-
initialMetadata: {
509-
is_remix: true,
510-
remix_of: {
511-
tracks: [{ parent_track_id: track.track_id }]
512-
}
513-
}
514-
})
515-
}, [navigation, track])
516-
517-
const renderRemixContestSection = () => {
518-
if (!isRemixContest) return null
519-
const isContestOver = dayjs(remixContest?.endDate).isBefore(dayjs())
520-
return (
521-
<Flex gap='m'>
522-
<Flex row gap='xs' alignItems='center'>
523-
<Text variant='label' color='accent'>
524-
{isContestOver ? messages.contestEnded : messages.contestDeadline}
525-
</Text>
526-
<Text size='s' strength='strong'>
527-
{messages.deadline(remixContest?.endDate)}
528-
</Text>
529-
</Flex>
530-
{!isOwner ? (
531-
<Flex flex={1}>
532-
<Button
533-
variant='secondary'
534-
size='small'
535-
iconLeft={IconCloudUpload}
536-
onPress={handlePressSubmitRemix}
537-
>
538-
{messages.uploadRemixButtonText}
539-
</Button>
540-
</Flex>
541-
) : null}
542-
</Flex>
543-
)
544-
}
545497
const renderBottomContent = () => {
546498
return hasDownloadableAssets ? (
547499
<>
@@ -705,7 +657,6 @@ export const TrackScreenDetailsTile = ({
705657
<TrackDescription description={description} scrollRef={scrollViewRef} />
706658
<TrackMetadataList trackId={trackId} />
707659
{renderTags()}
708-
{renderRemixContestSection()}
709660
<OfflineStatusRow contentId={trackId} isCollection={false} />
710661
{renderBottomContent()}
711662
</Flex>

packages/web/src/components/track/GiantTrackTile.tsx

Lines changed: 3 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
useStems,
88
useTrack
99
} from '@audius/common/api'
10-
import { useFeatureFlag } from '@audius/common/hooks'
1110
import {
1211
isContentUSDCPurchaseGated,
1312
ID,
@@ -16,19 +15,12 @@ import {
1615
AccessConditions,
1716
FavoriteSource
1817
} from '@audius/common/models'
19-
import { FeatureFlags } from '@audius/common/services'
2018
import {
2119
PurchaseableContentType,
2220
useEarlyReleaseConfirmationModal,
2321
usePublishConfirmationModal
2422
} from '@audius/common/store'
25-
import {
26-
Genre,
27-
Nullable,
28-
dayjs,
29-
formatReleaseDate,
30-
route
31-
} from '@audius/common/utils'
23+
import { Genre, Nullable, dayjs, formatReleaseDate } from '@audius/common/utils'
3224
import {
3325
Text,
3426
Box,
@@ -41,7 +33,6 @@ import {
4133
Button,
4234
MusicBadge,
4335
Paper,
44-
IconCloudUpload,
4536
PlainButton,
4637
IconCaretDown,
4738
IconCaretUp,
@@ -66,8 +57,6 @@ import Toast from 'components/toast/Toast'
6657
import Tooltip from 'components/tooltip/Tooltip'
6758
import { ComponentPlacement } from 'components/types'
6859
import { UserGeneratedText } from 'components/user-generated-text'
69-
import { useNavigateToPage } from 'hooks/useNavigateToPage'
70-
import { useRequiresAccountCallback } from 'hooks/useRequiresAccount'
7160

7261
import { AiTrackSection } from './AiTrackSection'
7362
import { CardTitle } from './CardTitle'
@@ -80,8 +69,6 @@ import { TrackDogEar } from './TrackDogEar'
8069
import { TrackMetadataList } from './TrackMetadataList'
8170
import { TrackStats } from './TrackStats'
8271

83-
const { UPLOAD_PAGE } = route
84-
8572
const DownloadSection = lazy(() =>
8673
import('./DownloadSection').then((module) => ({
8774
default: module.DownloadSection
@@ -215,7 +202,6 @@ export const GiantTrackTile = ({
215202
ddexApp,
216203
scrollToCommentSection
217204
}: GiantTrackTileProps) => {
218-
const navigate = useNavigateToPage()
219205
const [artworkLoading, setArtworkLoading] = useState(false)
220206
const onArtworkLoad = useCallback(
221207
() => setArtworkLoading(false),
@@ -226,12 +212,9 @@ export const GiantTrackTile = ({
226212
source: FavoriteSource.TRACK_PAGE
227213
})
228214

229-
const { isEnabled: isRemixContestEnabled } = useFeatureFlag(
230-
FeatureFlags.REMIX_CONTEST
231-
)
232215
const { data: remixContest, isLoading: isEventsLoading } =
233216
useRemixContest(trackId)
234-
const isRemixContest = isRemixContestEnabled && !!remixContest
217+
const isRemixContest = !!remixContest
235218

236219
const isLongFormContent =
237220
genre === Genre.PODCASTS || genre === Genre.AUDIOBOOKS
@@ -468,45 +451,6 @@ export const GiantTrackTile = ({
468451
)
469452
}
470453

471-
const goToUploadWithRemix = useRequiresAccountCallback(() => {
472-
if (!trackId) return
473-
474-
const state = {
475-
initialMetadata: {
476-
is_remix: true,
477-
remix_of: {
478-
tracks: [{ parent_track_id: trackId }]
479-
}
480-
}
481-
}
482-
navigate(UPLOAD_PAGE, state)
483-
}, [trackId, navigate])
484-
485-
const renderSubmitRemixContestSection = useCallback(() => {
486-
if (!isRemixContest) return null
487-
const isContestOver = dayjs(remixContest.endDate).isBefore(dayjs())
488-
return (
489-
<Flex row gap='m'>
490-
<Flex gap='xs' alignItems='center'>
491-
<Text variant='label' color='accent'>
492-
{isContestOver ? messages.contestEnded : messages.contestDeadline}
493-
</Text>
494-
<Text>{messages.deadline(remixContest.endDate)}</Text>
495-
</Flex>
496-
{!isOwner ? (
497-
<Button
498-
variant='secondary'
499-
size='small'
500-
onClick={goToUploadWithRemix}
501-
iconLeft={IconCloudUpload}
502-
>
503-
{messages.uploadRemixButtonText}
504-
</Button>
505-
) : null}
506-
</Flex>
507-
)
508-
}, [isRemixContest, remixContest, isOwner, goToUploadWithRemix])
509-
510454
const isLoading = loading || artworkLoading || isEventsLoading
511455

512456
const overflowMenuExtraItems = []
@@ -538,7 +482,7 @@ export const GiantTrackTile = ({
538482
includeEmbed: !(isUnlisted || isStreamGated),
539483
includeArtistPick: true,
540484
includeAddToAlbum: isOwner && !ddexApp,
541-
includeRemixContest: isRemixContestEnabled,
485+
includeRemixContest: true,
542486
extraMenuItems: overflowMenuExtraItems
543487
}
544488
}
@@ -756,7 +700,6 @@ export const GiantTrackTile = ({
756700
) : null}
757701

758702
{renderTags()}
759-
{renderSubmitRemixContestSection()}
760703
{hasDownloadableAssets ? (
761704
<Box w='100%'>
762705
<Suspense>

packages/web/src/pages/track-page/components/desktop/RemixContestDetailsTab.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@ import { ID } from '@audius/common/models'
33
import { dayjs } from '@audius/common/utils'
44
import { Flex, Text } from '@audius/harmony'
55

6+
import { UserGeneratedText } from 'components/user-generated-text'
7+
68
const messages = {
79
due: 'Submission Due:',
810
deadline: (deadline?: string) => {
911
if (!deadline) return ''
1012
const date = dayjs(deadline)
1113
return `${date.format('ddd. MMM D, YYYY')} at ${date.format('h:mm A')}`
12-
}
14+
},
15+
ended: 'Contest Ended',
16+
fallbackDescription:
17+
'Enter my remix contest before the deadline for your chance to win!'
1318
}
1419

1520
type RemixContestDetailsTabProps = {
@@ -23,21 +28,23 @@ export const RemixContestDetailsTab = ({
2328
trackId
2429
}: RemixContestDetailsTabProps) => {
2530
const { data: remixContest } = useRemixContest(trackId)
31+
const isContestEnded = dayjs(remixContest?.endDate).isBefore(dayjs())
32+
2633
return (
2734
<Flex column gap='l' p='xl'>
2835
<Flex row gap='s'>
2936
<Text variant='title' size='l' color='accent'>
3037
{messages.due}
3138
</Text>
3239
<Text variant='body' size='l' strength='strong'>
33-
{messages.deadline(remixContest?.endDate)}
40+
{isContestEnded
41+
? messages.ended
42+
: messages.deadline(remixContest?.endDate)}
3443
</Text>
3544
</Flex>
36-
<Text variant='body' size='l'>
37-
{
38-
"Join our exciting remix contest! Showcase your creativity by reimagining your favorite tracks. Submit your remixes for a chance to win amazing prizes and gain recognition in the music community. Don't miss out on this opportunity to shine!"
39-
}
40-
</Text>
45+
<UserGeneratedText variant='body' size='l'>
46+
{remixContest?.eventData?.description ?? messages.fallbackDescription}
47+
</UserGeneratedText>
4148
</Flex>
4249
)
4350
}
Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import { useRemixContest } from '@audius/common/api'
12
import { ID } from '@audius/common/models'
2-
import { Text, Flex } from '@audius/harmony'
3+
import { Flex } from '@audius/harmony'
4+
5+
import { UserGeneratedText } from 'components/user-generated-text'
36

47
type RemixContestPrizesTabProps = {
58
trackId: ID
@@ -11,26 +14,13 @@ type RemixContestPrizesTabProps = {
1114
export const RemixContestPrizesTab = ({
1215
trackId
1316
}: RemixContestPrizesTabProps) => {
17+
const { data: remixContest } = useRemixContest(trackId)
18+
1419
return (
1520
<Flex column gap='l' p='xl'>
16-
<Text variant='body' size='l'>
17-
{'Best Remix Award - $500'}
18-
</Text>
19-
<Text variant='body' size='l'>
20-
{'Audience Choice Award - $300'}
21-
</Text>
22-
<Text variant='body' size='l'>
23-
{'Most Creative Remix - $200'}
24-
</Text>
25-
<Text variant='body' size='l'>
26-
{'Best Use of Original Material - $250'}
27-
</Text>
28-
<Text variant='body' size='l'>
29-
{'Rising Star Award - $150'}
30-
</Text>
31-
<Text variant='body' size='l'>
32-
{'Honorable Mention - $100'}
33-
</Text>
21+
<UserGeneratedText variant='body' size='l'>
22+
{remixContest?.eventData?.prizeInfo}
23+
</UserGeneratedText>
3424
</Flex>
3525
)
3626
}

0 commit comments

Comments
 (0)