feat: support new advanced wallet settings
This commit is contained in:
parent
4120d58a1b
commit
ba72786dcb
7 changed files with 32 additions and 27 deletions
|
|
@ -11,7 +11,7 @@ const CheckboxInput = memo(
|
|||
disabledMessage = '',
|
||||
...props
|
||||
}) => {
|
||||
const { name, onChange, value } = props.field
|
||||
const { name, onChange, value = true } = props.field
|
||||
|
||||
const settings = {
|
||||
enabled: enabled,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ const GET_INFO = gql`
|
|||
`
|
||||
|
||||
const AdvancedWallet = () => {
|
||||
const ADVANCED = 'advanced'
|
||||
const ADVANCED = namespaces.ADVANCED
|
||||
const CRYPTOCURRENCY_KEY = 'cryptoCurrency'
|
||||
const SCREEN_KEY = namespaces.WALLETS
|
||||
const { data } = useQuery(GET_INFO)
|
||||
|
|
@ -44,22 +44,15 @@ const AdvancedWallet = () => {
|
|||
refetchQueries: () => ['getData']
|
||||
})
|
||||
|
||||
const mapConfigKeys = R.curry((fn, obj) =>
|
||||
R.zipObj(R.map(fn, R.keys(obj)), R.values(obj))
|
||||
)
|
||||
|
||||
const save = rawConfig => {
|
||||
const config = toNamespace(SCREEN_KEY)(
|
||||
mapConfigKeys(it => `${ADVANCED}_` + it, rawConfig.wallets[0])
|
||||
toNamespace(ADVANCED)(rawConfig.wallets[0])
|
||||
)
|
||||
|
||||
return saveConfig({ variables: { config } })
|
||||
}
|
||||
|
||||
const saveOverrides = rawConfig => {
|
||||
const config = toNamespace(SCREEN_KEY)(
|
||||
mapConfigKeys(it => `${ADVANCED}_` + it, rawConfig)
|
||||
)
|
||||
const config = toNamespace(SCREEN_KEY)(toNamespace(ADVANCED)(rawConfig))
|
||||
return saveConfig({ variables: { config } })
|
||||
}
|
||||
|
||||
|
|
@ -68,12 +61,8 @@ const AdvancedWallet = () => {
|
|||
|
||||
const cryptoCurrencies = data?.cryptoCurrencies ?? []
|
||||
|
||||
const AdvancedWalletSettings = mapConfigKeys(
|
||||
it => R.tail(R.split('_', it)),
|
||||
R.pickBy(
|
||||
(val, key) => R.head(R.split('_', key)) === ADVANCED,
|
||||
data?.config && fromNamespace(SCREEN_KEY)(data.config)
|
||||
)
|
||||
const AdvancedWalletSettings = fromNamespace(ADVANCED)(
|
||||
fromNamespace(SCREEN_KEY)(data?.config)
|
||||
)
|
||||
|
||||
const AdvancedWalletSettingsOverrides = AdvancedWalletSettings.overrides ?? []
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ const getAdvancedWalletElements = () => {
|
|||
stripe: true,
|
||||
width: 250,
|
||||
view: (_, ite) => {
|
||||
return ite.allowTransactionBatching ? 'Yes (Only BTC supports)' : `No`
|
||||
return ite.allowTransactionBatching ? 'Yes' : `No`
|
||||
},
|
||||
input: Checkbox
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import * as R from 'ramda'
|
||||
|
||||
const namespaces = {
|
||||
ADVANCED: 'advanced',
|
||||
CASH_IN: 'cashIn',
|
||||
CASH_OUT: 'cashOut',
|
||||
WALLETS: 'wallets',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue