feat: rbf checkbox in blockcypher settings

This commit is contained in:
José Oliveira 2021-04-06 00:23:06 +01:00 committed by Josh Harvey
parent e6b1446616
commit 0a4fbad335
2 changed files with 78 additions and 21 deletions

View file

@ -1,10 +1,20 @@
import { useQuery } from '@apollo/react-hooks'
import Checkbox from '@material-ui/core/Checkbox' import Checkbox from '@material-ui/core/Checkbox'
import { makeStyles } from '@material-ui/core/styles' import { makeStyles } from '@material-ui/core/styles'
import CheckBoxIcon from '@material-ui/icons/CheckBox' import CheckBoxIcon from '@material-ui/icons/CheckBox'
import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank' import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank'
import gql from 'graphql-tag'
import * as R from 'ramda'
import React from 'react' import React from 'react'
import { fontSize2, fontSize3, secondaryColor } from 'src/styling/variables' import { Label2, Info3 } from 'src/components/typography'
import { ReactComponent as WarningIcon } from 'src/styling/icons/warning-icon/comet.svg'
import {
fontSize2,
fontSize3,
secondaryColor,
offColor
} from 'src/styling/variables'
const useStyles = makeStyles({ const useStyles = makeStyles({
root: { root: {
@ -13,13 +23,46 @@ const useStyles = makeStyles({
color: secondaryColor color: secondaryColor
} }
}, },
checked: {} checked: {},
checkBoxLabel: {
display: 'flex'
},
wrapper: {
display: 'flex',
alignItems: 'center',
'& > svg': {
marginRight: 10
}
},
message: {
display: 'flex',
alignItems: 'center',
color: offColor,
margin: 0,
whiteSpace: 'break-spaces'
}
}) })
const CheckboxInput = ({ name, onChange, value, label, ...props }) => { const GET_INFO = gql`
query getData {
config
}
`
const CheckboxInput = ({ name, onChange, value, ...props }) => {
const { data: configData } = useQuery(GET_INFO)
const disabledMessage = 'RBF verification not available'
const label = 'Enable RBF verification'
const wallet = R.lensPath(['config', 'wallets_BTC_wallet'])
const isEnabled = R.equals(R.view(wallet, configData), 'bitcoind')
const classes = useStyles() const classes = useStyles()
return ( return (
<>
{isEnabled ? (
<div className={classes.checkBoxLabel}>
<Label2>{label}</Label2>
<Checkbox <Checkbox
id={name} id={name}
classes={{ classes={{
@ -38,6 +81,14 @@ const CheckboxInput = ({ name, onChange, value, label, ...props }) => {
disableRipple disableRipple
{...props} {...props}
/> />
</div>
) : (
<div className={classes.wrapper}>
<WarningIcon />
<Info3 className={classes.message}>{disabledMessage}</Info3>
</div>
)}
</>
) )
} }

View file

@ -1,5 +1,6 @@
import * as Yup from 'yup' import * as Yup from 'yup'
import CheckboxInput from 'src/components/inputs/formik/Checkbox'
import TextInputFormik from 'src/components/inputs/formik/TextInput' import TextInputFormik from 'src/components/inputs/formik/TextInput'
export default { export default {
@ -19,6 +20,11 @@ export default {
display: 'Confidence Factor', display: 'Confidence Factor',
component: TextInputFormik, component: TextInputFormik,
face: true face: true
},
{
code: 'rbf',
component: CheckboxInput,
face: true
} }
], ],
getValidationSchema: () => { getValidationSchema: () => {