Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
PAY-716 Take user to trending at end of BuyAudio flow (#2210)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickyrombo authored Nov 1, 2022
1 parent 6c12b8c commit edc298d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 16 deletions.
3 changes: 1 addition & 2 deletions packages/common/src/store/ui/buy-audio/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export const getAudioPurchaseInfoStatus = (state: CommonState) =>

export const getFeesCache = (state: CommonState) => state.ui.buyAudio.feesCache

export const getOnSuccessAction = (state: CommonState) =>
state.ui.buyAudio.onSuccessAction
export const getOnSuccess = (state: CommonState) => state.ui.buyAudio.onSuccess

export const getStripeSessionStatus = (state: CommonState) =>
state.ui.buyAudio.stripeSessionStatus
11 changes: 8 additions & 3 deletions packages/common/src/store/ui/buy-audio/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ type StripeSessionStatus =
| 'fulfillment_processing'
| 'fulfillment_complete'

type OnSuccess = {
action?: Action
message?: string
}

type BuyAudioState = {
stage: BuyAudioStage
error?: boolean
Expand All @@ -52,7 +57,7 @@ type BuyAudioState = {
transactionFees: number
}
provider: OnRampProvider
onSuccessAction?: Action
onSuccess?: OnSuccess
stripeSessionStatus?: StripeSessionStatus
}

Expand Down Expand Up @@ -116,13 +121,13 @@ const slice = createSlice({
state,
action: PayloadAction<{
provider: OnRampProvider
onSuccessAction?: Action
onSuccess?: OnSuccess
}>
) => {
state.stage = BuyAudioStage.START
state.error = undefined
state.provider = action.payload.provider
state.onSuccessAction = action.payload.onSuccessAction
state.onSuccess = action.payload.onSuccess
},
onRampOpened: (state, _action: PayloadAction<PurchaseInfo>) => {
state.stage = BuyAudioStage.PURCHASING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ const messages = {
const { getTransactionDetails } = transactionDetailsSelectors
const { setModalClosedAction: setOnTransactionDetailsModalClosedAction } =
transactionDetailsActions
const { getOnSuccessAction } = buyAudioSelectors
const { getOnSuccess } = buyAudioSelectors
const { setVisibility } = modalsActions

export const SuccessPage = () => {
const dispatch = useDispatch()
const transactionDetails = useSelector(getTransactionDetails)
const onSuccessAction = useSelector(getOnSuccessAction)
const onSuccess = useSelector(getOnSuccess)
const [, setModalVisibility] = useModalState('BuyAudio')
const [, setTransactionDetailsModalVisibility] =
useModalState('TransactionDetails')

const handleDoneClicked = useCallback(() => {
if (onSuccessAction) {
dispatch(onSuccessAction)
if (onSuccess?.action) {
dispatch(onSuccess.action)
dispatch(setOnTransactionDetailsModalClosedAction())
}
setModalVisibility(false)
}, [dispatch, setModalVisibility, onSuccessAction])
}, [dispatch, setModalVisibility, onSuccess])

const handleReviewTransactionClicked = useCallback(() => {
dispatch(
Expand Down Expand Up @@ -84,7 +84,7 @@ export const SuccessPage = () => {
</div>
</div>
<Button
text={messages.done}
text={onSuccess?.message ?? messages.done}
type={ButtonType.PRIMARY_ALT}
onClick={handleDoneClicked}
/>
Expand Down
4 changes: 3 additions & 1 deletion packages/web/src/components/tipping/tip-audio/SendTip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ export const SendTip = () => {
dispatch(
startBuyAudioFlow({
provider: OnRampProvider.STRIPE,
onSuccessAction: beginTip({ user: receiver, source: 'buyAudio' })
onSuccess: {
action: beginTip({ user: receiver, source: 'buyAudio' })
}
})
)
dispatch(resetSend())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
padding: 0 8px;
font-size: var(--font-m);
font-weight: var(--font-demi-bold);
color: var(--white);
color: var(--static-white);
background: linear-gradient(
315deg,
var(--page-header-gradient-color-1) 0%,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Tooltip from 'components/tooltip/Tooltip'
import { useFlag, useRemoteVar } from 'hooks/useRemoteConfig'
import { getLocation, Location } from 'services/Location'
import { isMobile } from 'utils/clientUtil'
import { pushUniqueRoute, TRENDING_PAGE } from 'utils/route'

import TokenHoverTooltip from './TokenHoverTooltip'
import styles from './WalletManagementTile.module.css'
Expand Down Expand Up @@ -62,7 +63,8 @@ const messages = {
`Link by Stripe is not supported in the state of ${state}`,
coinbaseStateNotSupported: (state: string) =>
`Coinbase Pay is not supported in the state of ${state}`,
goldAudioToken: 'Gold $AUDIO token'
goldAudioToken: 'Gold $AUDIO token',
findArtists: 'Find Artists to Support on Trending'
}

const AdvancedWalletActions = () => {
Expand Down Expand Up @@ -223,11 +225,27 @@ export const WalletManagementTile = () => {
}, [setOpen])

const onBuyWithCoinbaseClicked = useCallback(() => {
dispatch(startBuyAudioFlow({ provider: OnRampProvider.COINBASE }))
dispatch(
startBuyAudioFlow({
provider: OnRampProvider.COINBASE,
onSuccess: {
action: pushUniqueRoute(TRENDING_PAGE),
message: messages.findArtists
}
})
)
}, [dispatch])

const onBuyWithStripeClicked = useCallback(() => {
dispatch(startBuyAudioFlow({ provider: OnRampProvider.STRIPE }))
dispatch(
startBuyAudioFlow({
provider: OnRampProvider.STRIPE,
onSuccess: {
action: pushUniqueRoute(TRENDING_PAGE),
message: messages.findArtists
}
})
)
}, [dispatch])

return (
Expand Down

0 comments on commit edc298d

Please sign in to comment.