From 37f8d70221f4d191056c605c72f9b002beb5dc9f Mon Sep 17 00:00:00 2001 From: mperdomo-bc <97296851+mperdomo-bc@users.noreply.github.com> Date: Tue, 23 Jan 2024 15:29:08 -0300 Subject: [PATCH] feat(coinview): add notice about funds conversion (#6247) --- config/mocks/wallet-options-v4.json | 3 +- .../src/data/modules/profile/selectors.ts | 2 + .../src/data/modules/profile/types.ts | 3 ++ .../WalletBalanceDropdown/index.tsx | 54 ++++++++++++++++--- .../src/redux/walletOptions/selectors.ts | 2 + 5 files changed, 55 insertions(+), 9 deletions(-) diff --git a/config/mocks/wallet-options-v4.json b/config/mocks/wallet-options-v4.json index 2803a31e3aa..f111a24b41a 100644 --- a/config/mocks/wallet-options-v4.json +++ b/config/mocks/wallet-options-v4.json @@ -86,7 +86,8 @@ "useVgsProvider": true, "walletConnect": true, "walletDebitCardEnabled": true, - "proveEnabled": true + "proveEnabled": true, + "fiatTransformAlertEnabled": true } } }, diff --git a/packages/blockchain-wallet-v4-frontend/src/data/modules/profile/selectors.ts b/packages/blockchain-wallet-v4-frontend/src/data/modules/profile/selectors.ts index 125d2430776..d40bdbbecf1 100644 --- a/packages/blockchain-wallet-v4-frontend/src/data/modules/profile/selectors.ts +++ b/packages/blockchain-wallet-v4-frontend/src/data/modules/profile/selectors.ts @@ -87,6 +87,8 @@ export const getKycDocResubmissionStatus = compose( lift(path(['resubmission', 'reason'])), getUserData ) +export const getUserLegalEntity = (state: RootState) => + state.profile.userData.map((e) => e.userLegalEntity).getOrElse(undefined) export const getTiers = path(['profile', 'userTiers']) export const getTier = curry((state, tierIndex) => diff --git a/packages/blockchain-wallet-v4-frontend/src/data/modules/profile/types.ts b/packages/blockchain-wallet-v4-frontend/src/data/modules/profile/types.ts index 0079b40235e..48cffb2ac7d 100644 --- a/packages/blockchain-wallet-v4-frontend/src/data/modules/profile/types.ts +++ b/packages/blockchain-wallet-v4-frontend/src/data/modules/profile/types.ts @@ -102,6 +102,8 @@ export type UserTradingCurrencies = { userFiatCurrencies: WalletFiatType[] } +type UserLegalEntities = 'BC_BVI_2' | 'BC_INT' | 'BC_LT' | 'BC_LT_2' | 'BC_NG' | 'BC_US' + export type UserDataType = { address?: NabuAddressType currencies: UserTradingCurrencies @@ -120,6 +122,7 @@ export type UserDataType = { state: UserActivationStateType tags: TagsType tiers: Tiers + userLegalEntity: UserLegalEntities userName?: string walletAddresses: {} walletGuid: string diff --git a/packages/blockchain-wallet-v4-frontend/src/scenes/Transactions/WalletBalanceDropdown/index.tsx b/packages/blockchain-wallet-v4-frontend/src/scenes/Transactions/WalletBalanceDropdown/index.tsx index a1ec0ce7075..abd1b105ed3 100644 --- a/packages/blockchain-wallet-v4-frontend/src/scenes/Transactions/WalletBalanceDropdown/index.tsx +++ b/packages/blockchain-wallet-v4-frontend/src/scenes/Transactions/WalletBalanceDropdown/index.tsx @@ -8,6 +8,7 @@ import { Field } from 'redux-form' import styled from 'styled-components' import { coinToString, fiatToString } from '@core/exchange/utils' +import { getFiatTransformAlertEnabled } from '@core/redux/walletOptions/selectors' import { AddressTypesType, CoinfigType, @@ -23,6 +24,7 @@ import FiatDisplay from 'components/Display/FiatDisplay' import SelectBox from 'components/Form/SelectBox' import { actions } from 'data' import { convertBaseToStandard } from 'data/components/exchange/services' +import { getUserLegalEntity } from 'data/modules/profile/selectors' import { ModalName } from 'data/types' import { media } from 'services/styles' @@ -36,7 +38,7 @@ const Wrapper = styled.div` z-index: 2; margin-right: 30px; - ${media.laptop` + ${media.laptopL` width: auto; margin-right: 0px; `} @@ -50,11 +52,6 @@ const FiatNoticeWrapper = styled(Wrapper)` padding: 1rem; background-color: ${(props) => props.theme.grey000}; border-radius: 0.5rem; - - ${media.laptop` - width: auto; - margin-right: 0px; - `} ` const DisplayContainer = styled.div<{ isItem?: boolean }>` @@ -366,8 +363,28 @@ class WalletBalanceDropdown extends Component { ) } + showFiatTransformAlert = ({ userLegalEntity, ...rest }, coinfig: CoinfigType) => { + const balance = this.coinBalance(rest) || 0 + // If not FIAT nor has balance, do not show + if (coinfig.type.name !== 'FIAT' || balance <= 0) return false + + // Non BC_US with USD balance + const NON_BC_US_WITH_USD = userLegalEntity !== 'BC_US' && coinfig.displaySymbol === 'USD' + // Non BC_LT/BC_LT_2 with EUR/GBP balance + const ANY_BC_LT_WITH_EUR_GBP = + !userLegalEntity?.includes('BC_LT') && ['EUR', 'GBP'].includes(coinfig.displaySymbol) + + return NON_BC_US_WITH_USD || ANY_BC_LT_WITH_EUR_GBP + } + render() { - return this.props.data.cata({ + const { coin, data, fiatTransformAlertEnabled } = this.props + const { coinfig } = window.coins[coin] + + const showChangeAlert = + fiatTransformAlertEnabled && this.showFiatTransformAlert(this.props, coinfig) + + return data.cata({ Failure: (e) => {typeof e === 'string' ? e : 'Unknown Error'}, Loading: () => , NotAsked: () => , @@ -391,6 +408,25 @@ class WalletBalanceDropdown extends Component { templateItem={this.renderItem} /> + + {showChangeAlert && ( + + + Changes to {coin} Balances + + + Your {coinfig.name} ({coin}) balance will be converted to USDC daily at 12:00 am + UTC. To avoid any inconvenience, buy crypto or initiate a withdrawal before the + specified time. + + + )} ) } @@ -399,7 +435,9 @@ class WalletBalanceDropdown extends Component { } const mapStateToProps = (state, ownProps) => ({ - data: getData(state, ownProps) + data: getData(state, ownProps), + fiatTransformAlertEnabled: getFiatTransformAlertEnabled(state), + userLegalEntity: getUserLegalEntity(state) }) const mapDispatchToProps = (dispatch: Dispatch) => ({ diff --git a/packages/blockchain-wallet-v4/src/redux/walletOptions/selectors.ts b/packages/blockchain-wallet-v4/src/redux/walletOptions/selectors.ts index 9ff36e6e812..117fb7a068d 100644 --- a/packages/blockchain-wallet-v4/src/redux/walletOptions/selectors.ts +++ b/packages/blockchain-wallet-v4/src/redux/walletOptions/selectors.ts @@ -232,6 +232,8 @@ export const getImportedAddressSweep = (state: RootState) => export const getProveEnabled = (state: RootState) => getWebOptions(state).map(path(['featureFlags', 'proveEnabled'])) +export const getFiatTransformAlertEnabled = (state: RootState) => + getWebOptions(state).map(path(['featureFlags', 'fiatTransformAlertEnabled'])) // sofi // sofi associate before email verification export const getAssociateSofiBeforeEmailVerification = (state: RootState) =>