Skip to content

Commit

Permalink
feat(coinview): add notice about funds conversion (#6247)
Browse files Browse the repository at this point in the history
  • Loading branch information
mperdomo-bc committed Jan 26, 2024
1 parent b78249c commit 37f8d70
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 9 deletions.
3 changes: 2 additions & 1 deletion config/mocks/wallet-options-v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
"useVgsProvider": true,
"walletConnect": true,
"walletDebitCardEnabled": true,
"proveEnabled": true
"proveEnabled": true,
"fiatTransformAlertEnabled": true
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -120,6 +122,7 @@ export type UserDataType = {
state: UserActivationStateType
tags: TagsType
tiers: Tiers
userLegalEntity: UserLegalEntities
userName?: string
walletAddresses: {}
walletGuid: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'

Expand All @@ -36,7 +38,7 @@ const Wrapper = styled.div`
z-index: 2;
margin-right: 30px;
${media.laptop`
${media.laptopL`
width: auto;
margin-right: 0px;
`}
Expand All @@ -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 }>`
Expand Down Expand Up @@ -366,8 +363,28 @@ class WalletBalanceDropdown extends Component<Props> {
)
}

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) => <Text>{typeof e === 'string' ? e : 'Unknown Error'}</Text>,
Loading: () => <Loading />,
NotAsked: () => <Loading />,
Expand All @@ -391,6 +408,25 @@ class WalletBalanceDropdown extends Component<Props> {
templateItem={this.renderItem}
/>
</Wrapper>

{showChangeAlert && (
<FiatNoticeWrapper>
<Text
weight={600}
size='14px'
lineHeight='21px'
style={{ marginBottom: '8px' }}
color='grey900'
>
Changes to {coin} Balances
</Text>
<Text size='12px' color='grey900'>
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.
</Text>
</FiatNoticeWrapper>
)}
</>
)
}
Expand All @@ -399,7 +435,9 @@ class WalletBalanceDropdown extends Component<Props> {
}

const mapStateToProps = (state, ownProps) => ({
data: getData(state, ownProps)
data: getData(state, ownProps),
fiatTransformAlertEnabled: getFiatTransformAlertEnabled(state),
userLegalEntity: getUserLegalEntity(state)
})

const mapDispatchToProps = (dispatch: Dispatch) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down

0 comments on commit 37f8d70

Please sign in to comment.