Skip to content

Commit

Permalink
add whitelist for goodid flow
Browse files Browse the repository at this point in the history
  • Loading branch information
L03TJ3 committed Oct 11, 2024
1 parent f0d15dc commit 3d8caa3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/components/common/buttons/ClaimButton.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// @flow
import React from 'react'
import React, { useContext } from 'react'
import { Animated, Platform, View } from 'react-native'
import { noop } from 'lodash'

import { t } from '@lingui/macro'

import { useFlagWithPayload } from '../../../lib/hooks/useFeatureFlags'
import { GoodWalletContext } from '../../../lib/wallet/GoodWalletProvider'
import { PushButton } from '../../appNavigation/PushButton'
import { withStyles } from '../../../lib/styles'
import Config from '../../../config/config'
Expand Down Expand Up @@ -51,6 +53,10 @@ const ClaimButton = withStyles(getStylesFromProps)(({
const isPending = false
const canContinue = () => true

const { goodWallet } = useContext(GoodWalletContext)
const payload = useFlagWithPayload('uat-goodid-flow')
const { whitelist } = payload

// if there's no status the first time then get it
// otherwise just return true.
// in case we already have status then button is disabled if pending so its ok to return true here.
Expand All @@ -62,7 +68,7 @@ const ClaimButton = withStyles(getStylesFromProps)(({
<PushButton
disabled={isPending}
canContinue={canContinue}
routeName={Config.env !== 'development' ? 'Claim' : 'GoodIdOnboard'}
routeName={Config.env === 'development' || whitelist.includes(goodWallet.account) ? 'GoodIdOnboard' : 'Claim'}
testID="claim_button"
screenProps={screenProps}
style={[styles.claimButton, isPending ? styles.inQueue : undefined, style]}
Expand Down
9 changes: 6 additions & 3 deletions src/components/dashboard/Claim.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@ const Claim = props => {
const advanceClaimsCounter = useClaimCounter()
const [, , collectInviteBounty] = useInviteBonus()

const payload = useFlagWithPayload('next-tasks')
const nextTasks = useFlagWithPayload('next-tasks')
const uat = useFlagWithPayload('uat-goodid-flow')

const { tasks } = payload
const { tasks } = nextTasks
const { whitelist } = uat || {}

// format number of people who did claim today
const formattedNumberOfPeopleClaimedToday = useMemo(() => formatWithSIPrefix(peopleClaimed), [peopleClaimed])
Expand Down Expand Up @@ -310,7 +312,8 @@ const Claim = props => {
)

const handleFaceVerification = useCallback(() => {
const nextStep = Config.env !== 'development' ? 'FaceVerificationIntro' : 'GoodIdOnboard'
const nextStep =
Config.env === 'development' || whitelist.includes(goodWallet.account) ? 'GoodIdOnboard' : 'FaceVerificationIntro'
navigate(nextStep, { from: 'Claim' })
}, [navigate])

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useCallback, useContext, useMemo } from 'react'

import { identity } from 'lodash'

import { useFlagWithPayload } from '../../../lib/hooks/useFeatureFlags'
import Instructions from '../components/Instructions'

import Config from '../../../config/config'
Expand Down Expand Up @@ -35,6 +37,9 @@ const FaceVerification = ({ screenProps, navigation }) => {
const goodWallet = useWallet()
const userStorage = useUserStorage()
const { isFVFlow } = useContext(FVFlowContext)
const payload = useFlagWithPayload('uat-goodid-flow')
const { whitelist } = payload ?? {}

const { faceIdentifier: enrollmentIdentifier, chainId, v1FaceIdentifier: fvSigner } = useEnrollmentIdentifier()

// Redirects to the error screen, passing exception
Expand Down Expand Up @@ -142,7 +147,8 @@ const FaceVerification = ({ screenProps, navigation }) => {
userStorage.userProperties.set('fv2', true)
}

const nextStep = Config.env !== 'development' ? 'Claim' : 'GoodIdOnboard'
const nextStep =
Config.env === 'development' || whitelist.includes(goodWallet.account) ? 'GoodIdOnboard' : 'Claim'

//go to goodid to complete certificates
screenProps.navigateTo(nextStep, { isValid: true })
Expand Down
6 changes: 5 additions & 1 deletion src/components/goodid/GoodIdOnboard.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useCallback, useContext } from 'react'
import { View } from 'react-native'
import { GoodIdProvider, OnboardController } from '@gooddollar/good-design'

import { useFlagWithPayload } from '../../lib/hooks/useFeatureFlags'
import { GoodWalletContext } from '../../lib/wallet/GoodWalletProvider'
import { withStyles } from '../../lib/styles'
import Config from '../../config/config'
Expand All @@ -9,6 +11,8 @@ const GoodIdOnboardImpl = ({ screenProps, styles }) => {
// isValid is result from FV
const { navigateTo, isValid } = screenProps
const { goodWallet } = useContext(GoodWalletContext)
const payload = useFlagWithPayload('uat-goodid-flow')
const { whitelist } = payload ?? {}

const navigateToFV = useCallback(() => {
navigateTo('FaceVerificationIntro')
Expand All @@ -33,7 +37,7 @@ const GoodIdOnboardImpl = ({ screenProps, styles }) => {
onSkip={onSkip}
onDone={onSkip}
onExit={onExit}
isDev={Config.env !== 'production'}
isDev={Config.env === 'development' || whitelist.includes(goodWallet.account)}
isWallet={true}
/>
</GoodIdProvider>
Expand Down

0 comments on commit 3d8caa3

Please sign in to comment.