Skip to content

Commit 3a26a46

Browse files
authored
💇 Remove YPP requirements (Joystream#5008)
* Adjust logic layer * Adjust UI layer
1 parent debab0a commit 3a26a46

File tree

5 files changed

+15
-169
lines changed

5 files changed

+15
-169
lines changed

packages/atlas/src/hooks/useSegmentAnalytics.ts

-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useCallback, useRef } from 'react'
22

33
import { useSegmentAnalyticsContext } from '@/providers/segmentAnalytics/useSegmentAnalyticsContext'
4-
import { YppRequirementsErrorCode } from '@/views/global/YppLandingView/YppAuthorizationModal/YppAuthorizationModal.types'
54

65
export type videoPlaybackParams = {
76
videoId: string
@@ -350,17 +349,6 @@ export const useSegmentAnalytics = () => {
350349
[analytics]
351350
)
352351

353-
const trackYppReqsNotMet = useCallback(
354-
(
355-
errors: YppRequirementsErrorCode[],
356-
utmSource: string | null | undefined,
357-
utmCampaign: string | null | undefined
358-
) => {
359-
analytics.track('YPP Sign Up Failed - Reqs Not Met', { errors, utmSource, utmCampaign })
360-
},
361-
[analytics]
362-
)
363-
364352
const trackLogout = useCallback(() => {
365353
analytics.reset()
366354
}, [analytics])
@@ -432,7 +420,6 @@ export const useSegmentAnalytics = () => {
432420
trackVideoUpload,
433421
trackWithdrawnFunds,
434422
trackYppOptIn,
435-
trackYppReqsNotMet,
436423
trackYppSignInButtonClick,
437424
}
438425
}

packages/atlas/src/views/global/YppLandingView/YppAuthorizationModal/YppAuthorizationModal.tsx

+11-41
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ export const YppAuthorizationModal: FC<YppAuthorizationModalProps> = ({ unSynced
146146
trackPageView,
147147
trackYppOptIn,
148148
identifyUser,
149-
trackYppReqsNotMet,
150149
trackClickAuthModalSignUpButton,
151150
trackClickAuthModalSignInButton,
152151
} = useSegmentAnalytics()
@@ -155,10 +154,9 @@ export const YppAuthorizationModal: FC<YppAuthorizationModalProps> = ({ unSynced
155154

156155
const { displaySnackbar } = useSnackbar()
157156

158-
const { handleAuthorizeClick, ytRequirementsErrors, setYtRequirementsErrors, alreadyRegisteredChannel } =
159-
useYppGoogleAuth({
160-
channelsLoaded,
161-
})
157+
const { handleAuthorizeClick, alreadyRegisteredChannel } = useYppGoogleAuth({
158+
channelsLoaded,
159+
})
162160

163161
useEffect(() => {
164162
if (searchParams.get('utm_source')) {
@@ -175,18 +173,11 @@ export const YppAuthorizationModal: FC<YppAuthorizationModalProps> = ({ unSynced
175173
}, [trackPageView, yppModalOpenName])
176174

177175
const handleClose = useCallback(() => {
178-
setYtRequirementsErrors([])
179176
setReferrerId(null)
180177
setYppModalOpenName(null)
181178
setSelectedChannelId(null)
182179
setShouldContinueYppFlowAfterLogin(false)
183-
}, [
184-
setYppModalOpenName,
185-
setReferrerId,
186-
setSelectedChannelId,
187-
setShouldContinueYppFlowAfterLogin,
188-
setYtRequirementsErrors,
189-
])
180+
}, [setYppModalOpenName, setReferrerId, setSelectedChannelId, setShouldContinueYppFlowAfterLogin])
190181

191182
const handleGoBack = useCallback(() => {
192183
if (yppModalOpenName === 'ypp-sync-options') {
@@ -199,10 +190,9 @@ export const YppAuthorizationModal: FC<YppAuthorizationModalProps> = ({ unSynced
199190

200191
const handleSelectChannel = useCallback(
201192
(selectedChannelId: string) => {
202-
setYtRequirementsErrors([])
203193
setSelectedChannelId(selectedChannelId)
204194
},
205-
[setSelectedChannelId, setYtRequirementsErrors]
195+
[setSelectedChannelId]
206196
)
207197

208198
const createOrUpdateChannel = useCreateEditChannelSubmit()
@@ -350,13 +340,6 @@ export const YppAuthorizationModal: FC<YppAuthorizationModalProps> = ({ unSynced
350340
}
351341
}, [channel, detailsFormMethods, referrerId])
352342

353-
useEffect(() => {
354-
if (ytRequirementsErrors?.length) {
355-
trackPageView('YPP Reqs Not Met')
356-
trackYppReqsNotMet(ytRequirementsErrors, utmSource, utmCampaign)
357-
}
358-
}, [trackPageView, trackYppReqsNotMet, utmCampaign, utmSource, ytRequirementsErrors])
359-
360343
const selectedChannel = useMemo(() => {
361344
if (!unSyncedChannels || !selectedChannelId) {
362345
return null
@@ -380,13 +363,6 @@ export const YppAuthorizationModal: FC<YppAuthorizationModalProps> = ({ unSynced
380363
setSelectedChannelId(yppUnsyncedChannels[0].id)
381364
}
382365

383-
if (ytRequirementsErrors.length) {
384-
return {
385-
text: 'Close',
386-
onClick: handleClose,
387-
}
388-
}
389-
390366
if (yppUnsyncedChannels && yppUnsyncedChannels.length > 1) {
391367
return {
392368
text: 'Select channel',
@@ -406,13 +382,11 @@ export const YppAuthorizationModal: FC<YppAuthorizationModalProps> = ({ unSynced
406382
}
407383

408384
return {
409-
headerIcon: ytRequirementsErrors.length ? <SvgAlertsError32 /> : undefined,
410-
title: ytRequirementsErrors.length ? 'Authorization failed' : 'Requirements',
411-
description: ytRequirementsErrors.length
412-
? 'Looks like the YouTube channel you selected does not meet all conditions to be enrolled in the program. You can select another one or try again at a later time.'
413-
: 'Before you can apply to the program, make sure your YouTube channel meets the below conditions.',
385+
title: 'Requirements',
386+
description:
387+
'Before you can apply to the program, make sure your YouTube channel meets the below conditions.',
414388
primaryButton: getPrimaryButton(),
415-
component: <YppAuthorizationRequirementsStep requirmentsErrorCodes={ytRequirementsErrors} />,
389+
component: <YppAuthorizationRequirementsStep />,
416390
}
417391
}
418392

@@ -492,13 +466,11 @@ export const YppAuthorizationModal: FC<YppAuthorizationModalProps> = ({ unSynced
492466
handleSelectChannel,
493467
alreadyRegisteredChannel?.channelTitle,
494468
alreadyRegisteredChannel?.ownerMemberHandle,
495-
ytRequirementsErrors,
496469
isLoading,
497470
yppCurrentChannel,
498471
yppUnsyncedChannels,
499472
navigate,
500473
setSelectedChannelId,
501-
handleClose,
502474
setYppModalOpenName,
503475
trackClickAuthModalSignUpButton,
504476
utmSource,
@@ -510,7 +482,7 @@ export const YppAuthorizationModal: FC<YppAuthorizationModalProps> = ({ unSynced
510482
const isLoadingModal = yppModalOpenName === 'ypp-fetching-data' || yppModalOpenName === 'ypp-speaking-to-backend'
511483

512484
const secondaryButton: DialogButtonProps | undefined = useMemo(() => {
513-
if (isLoadingModal || ytRequirementsErrors.length) return
485+
if (isLoadingModal) return
514486

515487
if (yppModalOpenName === 'ypp-requirements' && isLoggedIn) return
516488

@@ -543,7 +515,6 @@ export const YppAuthorizationModal: FC<YppAuthorizationModalProps> = ({ unSynced
543515
}
544516
}, [
545517
isLoadingModal,
546-
ytRequirementsErrors.length,
547518
yppModalOpenName,
548519
isLoggedIn,
549520
isSubmitting,
@@ -567,8 +538,7 @@ export const YppAuthorizationModal: FC<YppAuthorizationModalProps> = ({ unSynced
567538
primaryButton={authorizationStep?.primaryButton}
568539
secondaryButton={secondaryButton}
569540
additionalActionsNode={
570-
!isLoadingModal &&
571-
!ytRequirementsErrors.length && (
541+
!isLoadingModal && (
572542
<Button variant="tertiary" disabled={isSubmitting} onClick={handleClose}>
573543
Cancel
574544
</Button>

packages/atlas/src/views/global/YppLandingView/YppAuthorizationModal/YppAuthorizationSteps/YppAuthorizationRequirementsStep/YppAuthorizationRequirementsStep.tsx

+4-64
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,23 @@
1-
import { formatDuration } from 'date-fns'
21
import { FC, PropsWithChildren } from 'react'
32

43
import { SvgActionCheck, SvgActionClose } from '@/assets/icons'
54
import { Banner } from '@/components/Banner'
6-
import { Text } from '@/components/Text'
75
import { atlasConfig } from '@/config'
8-
import { pluralizeNoun } from '@/utils/misc'
96

107
import { ListItem, Paragraph, StyledList, TickWrapper } from './YppAuthorizationRequirementsStep.styles'
11-
import { useGetYppChannelRequirements } from './useGetYppChannelRequirements'
128

13-
import { YppAuthorizationErrorCode, YppRequirementsErrorCode } from '../../YppAuthorizationModal.types'
14-
15-
type YppAuthorizationRequirementsStepProps = {
16-
requirmentsErrorCodes: YppRequirementsErrorCode[]
17-
}
18-
19-
const convertHoursRequirementTime = (hours: number) => {
20-
if (hours > 24 * 30) {
21-
return formatDuration({ months: Math.round(hours / (24 * 30)) })
22-
}
23-
if (hours > 24) {
24-
return formatDuration({ days: Math.round(hours / 24) })
25-
}
26-
return formatDuration({ hours: hours })
27-
}
28-
29-
export const YppAuthorizationRequirementsStep: FC<YppAuthorizationRequirementsStepProps> = ({
30-
requirmentsErrorCodes,
31-
}) => {
32-
const requirements = useGetYppChannelRequirements()
33-
const checkRequirmentError = (errorCode: YppAuthorizationErrorCode) =>
34-
!requirmentsErrorCodes.some((error) => error === errorCode)
35-
const hasAtLeastOneError = !!requirmentsErrorCodes.length
9+
export const YppAuthorizationRequirementsStep: FC = () => {
3610
return (
3711
<>
3812
<StyledList>
39-
<SingleRequirement fulfilled={checkRequirmentError(YppAuthorizationErrorCode.CHANNEL_STATUS_SUSPENDED)}>
40-
Original content, without reposts from other creators.
41-
</SingleRequirement>
42-
<SingleRequirement fulfilled={checkRequirmentError(YppAuthorizationErrorCode.CHANNEL_STATUS_SUSPENDED)}>
13+
<SingleRequirement fulfilled>Original content, without reposts from other creators.</SingleRequirement>
14+
<SingleRequirement fulfilled>
4315
Organic audience, without bots, purchased subscribers and fake comments.
4416
</SingleRequirement>
45-
<SingleRequirement
46-
fulfilled={checkRequirmentError(YppAuthorizationErrorCode.CHANNEL_CRITERIA_UNMET_CREATION_DATE)}
47-
>
48-
Channel must be older than {convertHoursRequirementTime(requirements?.MINIMUM_CHANNEL_AGE_HOURS || 0)}.
49-
</SingleRequirement>
50-
<SingleRequirement
51-
fulfilled={checkRequirmentError(YppAuthorizationErrorCode.CHANNEL_CRITERIA_UNMET_SUBSCRIBERS)}
52-
>
53-
Has at least{' '}
54-
<Text variant="t200" as="span" color="colorTextCaution">
55-
{pluralizeNoun(requirements?.MINIMUM_SUBSCRIBERS_COUNT ?? 0, 'subscriber', true)}
56-
</Text>
57-
.
58-
</SingleRequirement>
59-
<SingleRequirement fulfilled={checkRequirmentError(YppAuthorizationErrorCode.CHANNEL_CRITERIA_UNMET_VIDEOS)}>
60-
Has at least{' '}
61-
<Text variant="t200" as="span" color="colorTextCaution">
62-
{pluralizeNoun(requirements?.MINIMUM_TOTAL_VIDEOS_COUNT ?? 0, 'video', true)}
63-
</Text>
64-
, all of which are older than {convertHoursRequirementTime(requirements?.MINIMUM_VIDEO_AGE_HOURS || 0)}.
65-
</SingleRequirement>
66-
<SingleRequirement
67-
fulfilled={checkRequirmentError(YppAuthorizationErrorCode.CHANNEL_CRITERIA_UNMET_NEW_VIDEOS_REQUIREMENT)}
68-
>
69-
Has at least{' '}
70-
<Text variant="t200" as="span" color="colorTextCaution">
71-
{pluralizeNoun(requirements?.MINIMUM_VIDEOS_PER_MONTH ?? 0, 'video', true)} per month
72-
</Text>{' '}
73-
posted over the last {pluralizeNoun(requirements?.MONTHS_TO_CONSIDER ?? 0, 'month', true)}.
74-
</SingleRequirement>
75-
</StyledList>
76-
{!hasAtLeastOneError && (
7717
<Banner
7818
description={`${atlasConfig.general.appName} uses Google OAuth to get access to your public profile and account email address as part of sign up flow, and integrates with YouTube API to obtain details about your YouTube channel data, such as followers and video statistics.`}
7919
/>
80-
)}
20+
</StyledList>
8121
</>
8222
)
8323
}

packages/atlas/src/views/global/YppLandingView/YppAuthorizationModal/YppAuthorizationSteps/YppAuthorizationRequirementsStep/useGetYppChannelRequirements.ts

-31
This file was deleted.

packages/atlas/src/views/global/YppLandingView/YppAuthorizationModal/useYppGoogleAuth.tsx

-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useApolloClient } from '@apollo/client'
2-
import { isArray } from 'lodash-es'
32
import { useCallback, useEffect, useState } from 'react'
43
import { useMutation } from 'react-query'
54
import { useSearchParams } from 'react-router-dom'
@@ -26,7 +25,6 @@ import {
2625
ChannelVerificationErrorResponse,
2726
ChannelVerificationSuccessResponse,
2827
YppAuthorizationErrorCode,
29-
YppRequirementsErrorCode,
3028
} from './YppAuthorizationModal.types'
3129

3230
const GOOGLE_CONSOLE_CLIENT_ID = atlasConfig.features.ypp.googleConsoleClientId
@@ -54,8 +52,6 @@ export const useYppGoogleAuth = ({ channelsLoaded }: { channelsLoaded: boolean }
5452
const { isLoggedIn, isAuthenticating } = useAuth()
5553

5654
const { setYtStateParam: setYppAuthState, setSelectedChannelId } = useYppStore((state) => state.actions)
57-
const [ytRequirementsErrors, setYtRequirementsErrors] = useState<YppRequirementsErrorCode[]>([])
58-
5955
const [alreadyRegisteredChannel, setAlreadyRegisteredChannel] = useState<AlreadyRegisteredChannel | null>(null)
6056
const { mutateAsync: authMutation } = useMutation('ypp-auth-post', (authorizationCode: string) =>
6157
axiosInstance.post<ChannelVerificationSuccessResponse>(`${atlasConfig.features.ypp.youtubeSyncApiUrl}/users`, {
@@ -195,15 +191,6 @@ export const useYppGoogleAuth = ({ channelsLoaded }: { channelsLoaded: boolean }
195191
return
196192
}
197193

198-
const isRequirementsError = isArray(errorMessages)
199-
if (isRequirementsError) {
200-
const errorCodes = isRequirementsError ? errorMessages?.map((message) => message.code) : undefined
201-
202-
errorCodes && setYtRequirementsErrors(errorCodes)
203-
setYppModalOpenName('ypp-requirements')
204-
return
205-
}
206-
207194
if (errorResponseData && 'code' in errorResponseData) {
208195
switch (errorResponseData.code) {
209196
case YppAuthorizationErrorCode.YOUTUBE_QUOTA_LIMIT_EXCEEDED:
@@ -221,11 +208,6 @@ export const useYppGoogleAuth = ({ channelsLoaded }: { channelsLoaded: boolean }
221208
description: `You don't have a YouTube channel.`,
222209
iconType: 'error',
223210
})
224-
setYtRequirementsErrors([
225-
YppAuthorizationErrorCode.CHANNEL_CRITERIA_UNMET_CREATION_DATE,
226-
YppAuthorizationErrorCode.CHANNEL_CRITERIA_UNMET_VIDEOS,
227-
YppAuthorizationErrorCode.CHANNEL_CRITERIA_UNMET_SUBSCRIBERS,
228-
])
229211
setYppModalOpenName('ypp-requirements')
230212
return
231213
case YppAuthorizationErrorCode.CHANNEL_ALREADY_REGISTERED: {
@@ -311,8 +293,6 @@ export const useYppGoogleAuth = ({ channelsLoaded }: { channelsLoaded: boolean }
311293

312294
return {
313295
handleAuthorizeClick,
314-
setYtRequirementsErrors,
315-
ytRequirementsErrors,
316296
alreadyRegisteredChannel,
317297
}
318298
}

0 commit comments

Comments
 (0)