From 8f648cca8ec40d00808e86efc8516cf97534cb5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Tue, 6 Apr 2021 20:26:09 +0100 Subject: [PATCH] refactor: separate logic from checkbox component --- .../src/components/inputs/base/Checkbox.js | 20 +++------------ .../src/pages/Services/FormRenderer.js | 25 +++++++++++-------- .../src/pages/Services/Services.js | 11 ++++++++ .../src/pages/Services/schemas/blockcypher.js | 6 +++++ 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/new-lamassu-admin/src/components/inputs/base/Checkbox.js b/new-lamassu-admin/src/components/inputs/base/Checkbox.js index 9d414442..9ed04691 100644 --- a/new-lamassu-admin/src/components/inputs/base/Checkbox.js +++ b/new-lamassu-admin/src/components/inputs/base/Checkbox.js @@ -1,10 +1,7 @@ -import { useQuery } from '@apollo/react-hooks' import Checkbox from '@material-ui/core/Checkbox' import { makeStyles } from '@material-ui/core/styles' import CheckBoxIcon from '@material-ui/icons/CheckBox' import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank' -import gql from 'graphql-tag' -import * as R from 'ramda' import React from 'react' import { Label2, Info3 } from 'src/components/typography' @@ -43,24 +40,13 @@ const useStyles = makeStyles({ } }) -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 CheckboxInput = ({ name, onChange, value, settings, ...props }) => { + const { enabled, label, disabledMessage } = settings const classes = useStyles() return ( <> - {isEnabled ? ( + {enabled ? (
{label}
- {elements.map(({ component, code, display, inputProps }) => ( - - - - ))} + {elements.map( + ({ component, code, display, settings, inputProps }) => ( + + + + ) + )}