fix: remove blue dot next to buy (#6808)

* remove button

* remove dependencies

* fix: remove useBuyFiatFlowCompleted

* fix: update lint and unit tests

* fix: update user state

* fix: remove migration

* Revert "fix: remove migration"

This reverts commit eef313f9ce2ea6b494ce2c9bc4a2fa6dbd1991ee.

* test

* fix: add ts ignore
This commit is contained in:
Brendan Wong 2023-07-03 15:55:49 -04:00 committed by GitHub
parent 0a04cff7eb
commit 8e36361866
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 45 deletions

@ -75,7 +75,6 @@ describe('SwapBuyFiatButton.tsx', () => {
mockuseAccountDrawer.mockImplementation(() => [false, toggleWalletDrawer]) mockuseAccountDrawer.mockImplementation(() => [false, toggleWalletDrawer])
mockUseOpenModal.mockImplementation(() => useOpenModal) mockUseOpenModal.mockImplementation(() => useOpenModal)
render(<SwapBuyFiatButton />) render(<SwapBuyFiatButton />)
expect(screen.getByTestId('buy-fiat-flow-incomplete-indicator')).toBeInTheDocument()
await act(() => userEvent.click(screen.getByTestId('buy-fiat-button'))) await act(() => userEvent.click(screen.getByTestId('buy-fiat-button')))
expect(toggleWalletDrawer).toHaveBeenCalledTimes(0) expect(toggleWalletDrawer).toHaveBeenCalledTimes(0)
expect(useOpenModal).toHaveBeenCalledTimes(1) expect(useOpenModal).toHaveBeenCalledTimes(1)

@ -6,20 +6,12 @@ import { useAccountDrawer } from 'components/AccountDrawer'
import { ButtonText } from 'components/Button' import { ButtonText } from 'components/Button'
import { MouseoverTooltip } from 'components/Tooltip' import { MouseoverTooltip } from 'components/Tooltip'
import { useCallback, useEffect, useState } from 'react' import { useCallback, useEffect, useState } from 'react'
import { useBuyFiatFlowCompleted } from 'state/user/hooks'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { ExternalLink } from 'theme' import { ExternalLink } from 'theme'
import { useFiatOnrampAvailability, useOpenModal } from '../../state/application/hooks' import { useFiatOnrampAvailability, useOpenModal } from '../../state/application/hooks'
import { ApplicationModal } from '../../state/application/reducer' import { ApplicationModal } from '../../state/application/reducer'
const Dot = styled.div`
height: 8px;
width: 8px;
background-color: ${({ theme }) => theme.accentActive};
border-radius: 50%;
`
export const MOONPAY_REGION_AVAILABILITY_ARTICLE = export const MOONPAY_REGION_AVAILABILITY_ARTICLE =
'https://support.uniswap.org/hc/en-us/articles/11306664890381-Why-isn-t-MoonPay-available-in-my-region-' 'https://support.uniswap.org/hc/en-us/articles/11306664890381-Why-isn-t-MoonPay-available-in-my-region-'
@ -46,7 +38,6 @@ const StyledTextButton = styled(ButtonText)`
export default function SwapBuyFiatButton() { export default function SwapBuyFiatButton() {
const { account } = useWeb3React() const { account } = useWeb3React()
const openFiatOnRampModal = useOpenModal(ApplicationModal.FIAT_ONRAMP) const openFiatOnRampModal = useOpenModal(ApplicationModal.FIAT_ONRAMP)
const [buyFiatFlowCompleted, setBuyFiatFlowCompleted] = useBuyFiatFlowCompleted()
const [checkFiatRegionAvailability, setCheckFiatRegionAvailability] = useState(false) const [checkFiatRegionAvailability, setCheckFiatRegionAvailability] = useState(false)
const { const {
available: fiatOnrampAvailable, available: fiatOnrampAvailable,
@ -73,10 +64,8 @@ export default function SwapBuyFiatButton() {
setBuyFiatFlowState(BuyFiatFlowState.ACTIVE_NEEDS_ACCOUNT) setBuyFiatFlowState(BuyFiatFlowState.ACTIVE_NEEDS_ACCOUNT)
} else if (fiatOnrampAvailable && account) { } else if (fiatOnrampAvailable && account) {
openFiatOnRampModal() openFiatOnRampModal()
setBuyFiatFlowCompleted(true)
setBuyFiatFlowState(BuyFiatFlowState.INACTIVE) setBuyFiatFlowState(BuyFiatFlowState.INACTIVE)
} else if (!fiatOnrampAvailable) { } else if (!fiatOnrampAvailable) {
setBuyFiatFlowCompleted(true)
setBuyFiatFlowState(BuyFiatFlowState.INACTIVE) setBuyFiatFlowState(BuyFiatFlowState.INACTIVE)
} }
}, [ }, [
@ -86,7 +75,6 @@ export default function SwapBuyFiatButton() {
walletDrawerOpen, walletDrawerOpen,
toggleWalletDrawer, toggleWalletDrawer,
openFiatOnRampModal, openFiatOnRampModal,
setBuyFiatFlowCompleted,
]) ])
// Continue buy fiat flow automatically when requisite state changes have occured. // Continue buy fiat flow automatically when requisite state changes have occured.
@ -135,7 +123,6 @@ export default function SwapBuyFiatButton() {
> >
<StyledTextButton onClick={handleBuyCrypto} disabled={buyCryptoButtonDisabled} data-testid="buy-fiat-button"> <StyledTextButton onClick={handleBuyCrypto} disabled={buyCryptoButtonDisabled} data-testid="buy-fiat-button">
<Trans>Buy</Trans> <Trans>Buy</Trans>
{!buyFiatFlowCompleted && <Dot data-testid="buy-fiat-flow-incomplete-indicator" />}
</StyledTextButton> </StyledTextButton>
</TraceEvent> </TraceEvent>
</MouseoverTooltip> </MouseoverTooltip>

@ -115,13 +115,6 @@ exports[`SwapBuyFiatButton.tsx matches base snapshot 1`] = `
height: inherit; height: inherit;
} }
.c5 {
height: 8px;
width: 8px;
background-color: #4C82FB;
border-radius: 50%;
}
.c4 { .c4 {
color: #7780A0; color: #7780A0;
gap: 4px; gap: 4px;
@ -146,10 +139,6 @@ exports[`SwapBuyFiatButton.tsx matches base snapshot 1`] = `
data-testid="buy-fiat-button" data-testid="buy-fiat-button"
> >
Buy Buy
<div
class="c5"
data-testid="buy-fiat-flow-incomplete-indicator"
/>
</button> </button>
</div> </div>
</div> </div>

@ -19,7 +19,6 @@ import {
addSerializedToken, addSerializedToken,
updateHideClosedPositions, updateHideClosedPositions,
updateHideUniswapWalletBanner, updateHideUniswapWalletBanner,
updateUserBuyFiatFlowCompleted,
updateUserDeadline, updateUserDeadline,
updateUserLocale, updateUserLocale,
updateUserRouterPreference, updateUserRouterPreference,
@ -65,18 +64,6 @@ export function useUserLocaleManager(): [SupportedLocale | null, (newLocale: Sup
return [locale, setLocale] return [locale, setLocale]
} }
export function useBuyFiatFlowCompleted(): [boolean | undefined, (buyFiatFlowCompleted: boolean) => void] {
const dispatch = useAppDispatch()
const buyFiatFlowCompleted = useAppSelector((state) => state.user.buyFiatFlowCompleted)
const setBuyFiatFlowCompleted = useCallback(
(buyFiatFlowCompleted: boolean) => {
dispatch(updateUserBuyFiatFlowCompleted(buyFiatFlowCompleted))
},
[dispatch]
)
return [buyFiatFlowCompleted, setBuyFiatFlowCompleted]
}
export function useRouterPreference(): [RouterPreference, (routerPreference: RouterPreference) => void] { export function useRouterPreference(): [RouterPreference, (routerPreference: RouterPreference) => void] {
const dispatch = useAppDispatch() const dispatch = useAppDispatch()

@ -10,8 +10,6 @@ import { SerializedPair, SerializedToken, SlippageTolerance } from './types'
const currentTimestamp = () => new Date().getTime() const currentTimestamp = () => new Date().getTime()
export interface UserState { export interface UserState {
buyFiatFlowCompleted?: boolean
selectedWallet?: ConnectionType selectedWallet?: ConnectionType
// the timestamp of the last updateVersion action // the timestamp of the last updateVersion action
@ -59,7 +57,6 @@ function pairKey(token0Address: string, token1Address: string) {
} }
export const initialState: UserState = { export const initialState: UserState = {
buyFiatFlowCompleted: undefined,
selectedWallet: undefined, selectedWallet: undefined,
userLocale: null, userLocale: null,
userRouterPreference: RouterPreference.AUTO, userRouterPreference: RouterPreference.AUTO,
@ -79,9 +76,6 @@ const userSlice = createSlice({
name: 'user', name: 'user',
initialState, initialState,
reducers: { reducers: {
updateUserBuyFiatFlowCompleted(state, action) {
state.buyFiatFlowCompleted = action.payload
},
updateSelectedWallet(state, { payload: { wallet } }) { updateSelectedWallet(state, { payload: { wallet } }) {
state.selectedWallet = wallet state.selectedWallet = wallet
}, },
@ -169,6 +163,13 @@ const userSlice = createSlice({
state.userRouterPreference = RouterPreference.AUTO state.userRouterPreference = RouterPreference.AUTO
} }
//If `buyFiatFlowCompleted` is present, delete it using filtering
if ('buyFiatFlowCompleted' in state) {
//ignoring due to type errors occuring since we now remove this state
//@ts-ignore
delete state.buyFiatFlowCompleted
}
state.lastUpdateVersionTimestamp = currentTimestamp() state.lastUpdateVersionTimestamp = currentTimestamp()
}) })
}, },
@ -177,7 +178,6 @@ const userSlice = createSlice({
export const { export const {
addSerializedPair, addSerializedPair,
addSerializedToken, addSerializedToken,
updateUserBuyFiatFlowCompleted,
updateSelectedWallet, updateSelectedWallet,
updateHideClosedPositions, updateHideClosedPositions,
updateUserRouterPreference, updateUserRouterPreference,