Skip to content

Commit

Permalink
feat(pit): get invited status and hide/show banners
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Jul 24, 2019
1 parent d936cad commit 31eb445
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 50 deletions.
3 changes: 3 additions & 0 deletions config/mocks/wallet-options-v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@
"iSignThisDomain": "https://stage-coinify-verify.isignthis.com"
}
},
"thePit": {
"countries": ["UK"]
},
"sfox": {
"countries": ["US"],
"states": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
findLast,
hasPath,
lift,
includes,
isNil,
not,
path,
Expand Down Expand Up @@ -92,9 +93,27 @@ export const getLastAttemptedTier = compose(

export const isCountrySupported = (countryCode, supportedCountries) =>
any(propEq('code', countryCode), supportedCountries)
export const invitedToKyc = state =>
export const isInvitedToKyc = state =>
selectors.core.settings.getInvitations(state).map(prop('kyc'))
export const userFlowSupported = invitedToKyc
export const userFlowSupported = isInvitedToKyc

export const isInvitedToPit = state => {
const pitCountries = selectors.core.walletOptions.getPitCountryList(state)
const userCountry = selectors.core.settings.getCountryCode(state)
const isInvited = selectors.core.settings
.getInvitations(state)
.map(prop('pit'))

const transform = (pitCountries, userCountry, isInvited) => {
const isCountryWhitelisted =
pitCountries &&
(pitCountries === '*' || includes(userCountry, pitCountries))

return isCountryWhitelisted || isInvited
}

return lift(transform)(pitCountries, userCountry, isInvited)
}

export const getApiToken = path(['profile', 'apiToken'])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class NavigationContainer extends React.PureComponent {
actions,
domains,
isPitAccountLinked,
isInvitedToPit,
supportedCoins,
...props
} = this.props
Expand All @@ -21,6 +22,7 @@ class NavigationContainer extends React.PureComponent {
{...props}
handleCloseMenu={actions.layoutWalletMenuCloseClicked}
isPitAccountLinked={isPitAccountLinked}
isInvitedToPit={isInvitedToPit}
pitUrl={concat(prop('thePit', domains), '/trade')}
supportedCoins={supportedCoins}
/>
Expand All @@ -30,6 +32,9 @@ class NavigationContainer extends React.PureComponent {

const mapStateToProps = state => ({
domains: selectors.core.walletOptions.getDomains(state).getOrElse({}),
isInvitedToPit: selectors.modules.profile
.isInvitedToPit(state)
.getOrElse(false),
isPitAccountLinked: selectors.modules.profile
.isPitAccountLinked(state)
.getOrElse(false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ const NewCartridge = styled(Cartridge)`
border: 1px solid ${props => props.theme['gray-1']};
border-radius: 4px;
`

const renderPitLinkContent = () => {
return (
<React.Fragment>
<MenuIcon name='the-pit' style={{ paddingLeft: '2px' }} size='24px' />
<Destination>
<FormattedMessage
id='layouts.wallet.menuleft.navigation.thepit'
defaultMessage='The PIT'
/>
</Destination>
</React.Fragment>
)
}

const Navigation = props => {
const { ...rest } = props
const {
Expand Down Expand Up @@ -183,53 +198,33 @@ const Navigation = props => {
coinOrder
)
)}
<Separator />
{props.isPitAccountLinked ? (
<Link
href={props.pitUrl}
rel='noopener noreferrer'
target='_blank'
style={{ width: '100%' }}
>
<MenuItem data-e2e='thePitLink'>
<MenuIcon
name='the-pit'
style={{ paddingLeft: '2px' }}
size='24px'
/>
<Destination>
<FormattedMessage
id='layouts.wallet.menuleft.navigation.thepit'
defaultMessage='The PIT'
/>
</Destination>
</MenuItem>
</Link>
) : (
<LinkContainer to='/thepit' activeClassName='active'>
<MenuItem data-e2e='thePitLink'>
<MenuIcon
name='the-pit'
style={{ paddingLeft: '2px' }}
size='24px'
/>
<Destination>
<FormattedMessage
id='layouts.wallet.menuleft.navigation.thepit'
defaultMessage='The PIT'
/>
</Destination>
<NewCartridge>
<Text color='orange' size='12' weight={500} uppercase>
<FormattedMessage
id='layouts.wallet.menuleft.navigation.transactions.new'
defaultMessage='New'
/>
</Text>
</NewCartridge>
</MenuItem>
</LinkContainer>
)}
{props.isInvitedToPit && <Separator />}
{props.isInvitedToPit ? (
props.isPitAccountLinked ? (
<Link
href={props.pitUrl}
rel='noopener noreferrer'
target='_blank'
style={{ width: '100%' }}
>
<MenuItem data-e2e='thePitLink'>{renderPitLinkContent()}</MenuItem>
</Link>
) : (
<LinkContainer to='/thepit' activeClassName='active'>
<MenuItem data-e2e='thePitLink'>
{renderPitLinkContent()}
<NewCartridge>
<Text color='orange' size='12' weight={500} uppercase>
<FormattedMessage
id='layouts.wallet.menuleft.navigation.transactions.new'
defaultMessage='New'
/>
</Text>
</NewCartridge>
</MenuItem>
</LinkContainer>
)
) : null}
</Wrapper>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ export const getData = state => {
const isPitAccountLinked = selectors.modules.profile
.isPitAccountLinked(state)
.getOrElse(true)
const isInvitedToPit = selectors.modules.profile
.isInvitedToPit(state)
.getOrElse(false)

let bannerToShow
if (showDocResubmitBanner) {
bannerToShow = 'resubmit'
} else if (!isPitAccountLinked) {
} else if (isInvitedToPit && !isPitAccountLinked) {
bannerToShow = 'thepit'
} else {
bannerToShow = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export const getCoinIcons = (state, coin) =>
export const getVeriffDomain = state => getDomains(state).map(prop('veriff'))
export const getThePitDomain = state => getDomains(state).map(prop('thePit'))

// pit
export const getPitCountryList = state =>
getWebOptions(state).map(path(['thePit', 'countries']))

// partners
export const getSFOXCountries = state =>
getWebOptions(state).map(path(['sfox', 'countries']))
Expand Down

0 comments on commit 31eb445

Please sign in to comment.