fix: added missing lodash dependency to accounts lib

fix: removed unnecessary properties from CAR page and config

style: changed the CAR page properties from radio groups to switches

fix: refetch config after saving
This commit is contained in:
Liordino Neto 2020-07-02 20:08:31 -03:00 committed by Josh Harvey
parent 5dd8501a17
commit fbb72e9562
6 changed files with 2131 additions and 2199 deletions

View file

@ -1,5 +1,6 @@
const _ = require('lodash/fp') const _ = require('lodash/fp')
const { COINS, ALL_CRYPTOS } = require('./coins') const { COINS, ALL_CRYPTOS } = require('./coins')
const _ = require('lodash/fp')
const { BTC, BCH, DASH, ETH, LTC, ZEC } = COINS const { BTC, BCH, DASH, ETH, LTC, ZEC } = COINS

View file

@ -25435,8 +25435,7 @@
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
@ -25479,8 +25478,7 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
@ -25491,8 +25489,7 @@
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -25609,8 +25606,7 @@
"inherits": { "inherits": {
"version": "2.0.4", "version": "2.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -25622,7 +25618,6 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -25652,7 +25647,6 @@
"version": "2.9.0", "version": "2.9.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -25671,7 +25665,6 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -25774,7 +25767,6 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -25860,8 +25852,7 @@
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
@ -25897,7 +25888,6 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -25917,7 +25907,6 @@
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@ -25961,14 +25950,12 @@
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.1.1", "version": "3.1.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
} }
} }
}, },

View file

@ -5,8 +5,6 @@ import * as R from 'ramda'
import React, { useState, memo } from 'react' import React, { useState, memo } from 'react'
import Popper from 'src/components/Popper' import Popper from 'src/components/Popper'
import { BooleanPropertiesTable } from 'src/components/booleanPropertiesTable'
import { Button } from 'src/components/buttons'
import { Switch } from 'src/components/inputs' import { Switch } from 'src/components/inputs'
import { H4, P, Label2 } from 'src/components/typography' import { H4, P, Label2 } from 'src/components/typography'
import { ReactComponent as HelpIcon } from 'src/styling/icons/action/help/zodiac.svg' import { ReactComponent as HelpIcon } from 'src/styling/icons/action/help/zodiac.svg'
@ -18,15 +16,8 @@ const useStyles = makeStyles(mainStyles)
const initialValues = { const initialValues = {
active: false, active: false,
// location: false,
commissions: false, commissions: false,
supportedCryptocurrencies: false,
supportedFiat: false,
supportedBuySellDirection: false,
limitsAndVerification: false limitsAndVerification: false
// operatorName: false,
// operatorPhoneNumber: false,
// operatorEmail: false
} }
const GET_CONFIG = gql` const GET_CONFIG = gql`
@ -41,19 +32,31 @@ const SAVE_CONFIG = gql`
} }
` `
const Row = memo(({ title, disabled = false, checked, save, label }) => {
const classes = useStyles()
return (
<div className={classes.rowWrapper}>
<div className={classes.rowTextAndSwitch}>
<P>{title}</P>
<Switch
disabled={disabled}
checked={checked}
onChange={event => save && save(event.target.checked)}
/>
</div>
{label && <Label2>{label}</Label2>}
</div>
)
})
const CoinATMRadar = memo(() => { const CoinATMRadar = memo(() => {
const [helpPopperAnchorEl, setHelpPopperAnchorEl] = useState(null) const [helpPopperAnchorEl, setHelpPopperAnchorEl] = useState(null)
const [coinAtmRadarConfig, setCoinAtmRadarConfig] = useState(null) const [coinAtmRadarConfig, setCoinAtmRadarConfig] = useState(null)
const classes = useStyles() const classes = useStyles()
const [saveConfig] = useMutation(SAVE_CONFIG, { const { refetch: getCoinAtmRadarConfig } = useQuery(GET_CONFIG, {
onCompleted: configResponse =>
setCoinAtmRadarConfig(
fromNamespace(namespaces.COIN_ATM_RADAR, configResponse.saveConfig)
)
})
useQuery(GET_CONFIG, {
onCompleted: configResponse => { onCompleted: configResponse => {
const response = fromNamespace( const response = fromNamespace(
namespaces.COIN_ATM_RADAR, namespaces.COIN_ATM_RADAR,
@ -64,6 +67,16 @@ const CoinATMRadar = memo(() => {
} }
}) })
const [saveConfig] = useMutation(SAVE_CONFIG, {
onCompleted: configResponse => {
setCoinAtmRadarConfig(
fromNamespace(namespaces.COIN_ATM_RADAR, configResponse.saveConfig)
)
getCoinAtmRadarConfig()
}
})
const save = it => const save = it =>
saveConfig({ saveConfig({
variables: { config: toNamespace(namespaces.COIN_ATM_RADAR, it) } variables: { config: toNamespace(namespaces.COIN_ATM_RADAR, it) }
@ -84,7 +97,7 @@ const CoinATMRadar = memo(() => {
return ( return (
<div className={classes.content}> <div className={classes.content}>
<div> <div>
<div className={classes.rowWrapper}> <div className={classes.titleWrapper}>
<H4>Coin ATM Radar share settings</H4> <H4>Coin ATM Radar share settings</H4>
<div className={classes.transparentButton}> <div className={classes.transparentButton}>
<button onClick={handleOpenHelpPopper}> <button onClick={handleOpenHelpPopper}>
@ -111,88 +124,26 @@ const CoinATMRadar = memo(() => {
</button> </button>
</div> </div>
</div> </div>
<div className={classes.rowWrapper}> <Row
<P>Share information?</P> title={'Share information?'}
<div className={classes.switchWrapper}> checked={coinAtmRadarConfig.active}
<Switch save={value => save({ active: value })}
checked={coinAtmRadarConfig.active} label={coinAtmRadarConfig.active ? 'Yes' : 'No'}
onChange={event =>
save({
active: event.target.checked
})
}
/>
</div>
<Label2>{coinAtmRadarConfig.active ? 'Yes' : 'No'}</Label2>
</div>
<BooleanPropertiesTable
title={'Machine info'}
disabled={!coinAtmRadarConfig.active}
data={coinAtmRadarConfig}
elements={[
// {
// name: 'location',
// display: 'Location',
// value: coinAtmRadarConfig.location
// },
{
name: 'commissions',
display: 'Commissions',
value: coinAtmRadarConfig.commissions
},
{
name: 'supportedCryptocurrencies',
display: 'Supported Cryptocurrencies',
value: coinAtmRadarConfig.supportedCryptocurrencies
},
{
name: 'supportedFiat',
display: 'Supported Fiat',
value: coinAtmRadarConfig.supportedFiat
},
{
name: 'supportedBuySellDirection',
display: 'Supported Buy Sell Direction',
value: coinAtmRadarConfig.supportedBuySellDirection
},
{
name: 'limitsAndVerification',
display: 'Limits And Verification',
value: coinAtmRadarConfig.limitsAndVerification
}
]}
save={save}
/> />
{/* <BooleanPropertiesTable <H4>{'Machine info'}</H4>
title={'Operator info'} <Row
title={'Commissions'}
disabled={!coinAtmRadarConfig.active} disabled={!coinAtmRadarConfig.active}
data={coinAtmRadarConfig} checked={coinAtmRadarConfig.commissions}
elements={[ save={value => save({ commissions: value })}
{ />
name: 'operatorName', <Row
display: 'Operator Name', title={'Limits and verification'}
value: coinAtmRadarConfig.operatorName disabled={!coinAtmRadarConfig.active}
}, checked={coinAtmRadarConfig.limitsAndVerification}
{ save={value => save({ limitsAndVerification: value })}
name: 'operatorPhoneNumber', />
display: 'Operator Phone Number',
value: coinAtmRadarConfig.operatorPhoneNumber
},
{
name: 'operatorEmail',
display: 'Operator Email',
value: coinAtmRadarConfig.operatorEmail
}
]}
save={save}
/> */}
</div> </div>
<a
target="_blank"
rel="noopener noreferrer"
href="https://coinatmradar.com/">
<Button>Coin ATM Radar page</Button>
</a>
</div> </div>
) )
}) })

View file

@ -1,18 +1,15 @@
import baseStyles from 'src/pages/Logs.styles' import baseStyles from 'src/pages/Logs.styles'
import { booleanPropertiesTableStyles } from 'src/components/booleanPropertiesTable/BooleanPropertiesTable.styles'
const { button } = baseStyles const { button } = baseStyles
const { rowWrapper } = booleanPropertiesTableStyles
const mainStyles = { const mainStyles = {
button, button,
content: { content: {
display: 'flex', display: 'flex'
justifyContent: 'space-between'
}, },
transparentButton: { transparentButton: {
'& > *': { '& > *': {
margin: 'auto 15px' margin: 'auto 10px'
}, },
'& button': { '& button': {
border: 'none', border: 'none',
@ -20,10 +17,22 @@ const mainStyles = {
cursor: 'pointer' cursor: 'pointer'
} }
}, },
rowWrapper, titleWrapper: {
switchWrapper: {
display: 'flex', display: 'flex',
marginLeft: 120 alignItems: 'center',
flex: 'wrap'
},
rowWrapper: {
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between'
},
rowTextAndSwitch: {
display: 'flex',
flex: 'wrap',
alignItems: 'center',
justifyContent: 'space-between',
width: 285
}, },
popoverContent: { popoverContent: {
width: 272, width: 272,

4131
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -43,9 +43,6 @@
}, },
"coinAtmRadar_active": true, "coinAtmRadar_active": true,
"coinAtmRadar_commissions": true, "coinAtmRadar_commissions": true,
"coinAtmRadar_supportedCryptocurrencies": true,
"coinAtmRadar_supportedFiat": true,
"coinAtmRadar_supportedBuySellDirection": true,
"coinAtmRadar_limitsAndVerification": true, "coinAtmRadar_limitsAndVerification": true,
"termsConditions_active": true, "termsConditions_active": true,
"termsConditions_title": "Rasdkl", "termsConditions_title": "Rasdkl",