Skip to content

Commit

Permalink
feat(FAQ): filter faq content by partner availability
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Jun 18, 2018
1 parent 89a8106 commit 79ff3db
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
Expand Up @@ -11,7 +11,7 @@ class NavigationContainer extends React.PureComponent {
render () {
return (
<Navigation
canBuy={this.props.canBuy}
canTrade={this.props.canTrade}
settingsOpened={this.props.settingsOpened}
menuOpened={this.props.menuOpened}
pathname={this.props.pathname}
Expand Down
@@ -1,6 +1,5 @@
import { selectors } from 'data'
import { createDeepEqualSelector } from 'services/ReselectHelper'
import { Remote } from 'blockchain-wallet-v4/src'

export const getData = createDeepEqualSelector(
[
Expand All @@ -9,8 +8,8 @@ export const getData = createDeepEqualSelector(
selectors.exchange.getCanTrade,
selectors.router.getPathname
],
(menuOpened, settingsOpened, canTrade, pathname) => {
const canBuy = Remote.Success.is(canTrade)
return { menuOpened, settingsOpened, canBuy, pathname }
(menuOpened, settingsOpened, canTradeR, pathname) => {
const canTrade = canTradeR.getOrElse(false)
return { menuOpened, settingsOpened, canTrade, pathname }
}
)
Expand Up @@ -63,7 +63,7 @@ const SubMenuItem = styled.li`
`

const Navigation = props => {
const { menuOpened, settingsOpened, handleCloseMenu, canBuy, pathname, ...rest } = props
const { menuOpened, settingsOpened, handleCloseMenu, canTrade, pathname, ...rest } = props

return (
<Wrapper {...rest}>
Expand Down Expand Up @@ -102,7 +102,7 @@ const Navigation = props => {
<MenuItem>
<Separator />
</MenuItem>
{canBuy && (
{canTrade && (
<LinkContainer to='/buy-sell' activeClassName='active'>
<MenuItem>
<Icon name='cart-filled' />
Expand Down Expand Up @@ -156,7 +156,7 @@ const Navigation = props => {
Navigation.propTypes = {
menuOpened: PropTypes.bool.isRequired,
settingsOpened: PropTypes.bool.isRequired,
canBuy: PropTypes.bool.isRequired,
canTrade: PropTypes.bool.isRequired,
pathname: PropTypes.string.isRequired,
handleCloseMenu: PropTypes.func.isRequired
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -5,13 +5,16 @@ import { any, assoc, contains, curry, filter, map, path, toLower } from 'ramda'

import FaqContent from './FaqContent'
import { getData } from './selectors'
import { selectors } from 'data'
import Faq from './template.js'

class FaqContainer extends React.PureComponent {
render () {
const { data, handleTrayRightToggle } = this.props
const { data, canTrade, handleTrayRightToggle } = this.props
const { search } = data

const partner = canTrade.cata({ Success: (val) => val || 'n/a', Loading: () => false, Failure: () => false, NotAsked: () => false })

// Search for matching messages in the component subtree starting
const containsRecursive = curry((search, x) => {
if (path(['props', 'defaultMessage'], x)) {
Expand All @@ -23,6 +26,10 @@ class FaqContainer extends React.PureComponent {
}
})

const whitelistContent = (contentPart) => {
return contentPart.whitelist ? contentPart.whitelist.includes(partner) : true
}

const filterContent = (contentPart) => {
if (search) {
const filteredGroupQuestions = filter(q =>
Expand All @@ -34,14 +41,18 @@ class FaqContainer extends React.PureComponent {
}
}

const whitelistedContent = filter(whitelistContent, FaqContent)
const filteredContent = map(filterContent, whitelistedContent)

return (
<Faq filteredContent={map(filterContent, FaqContent)} handleTrayRightToggle={handleTrayRightToggle} />
<Faq filteredContent={filteredContent} handleTrayRightToggle={handleTrayRightToggle} />
)
}
}

const mapStateToProps = (state) => ({
data: getData(state)
data: getData(state),
canTrade: selectors.exchange.getCanTrade(state)
})

FaqContainer.contextTypes = {
Expand Down

0 comments on commit 79ff3db

Please sign in to comment.