fix: wizard rework

This commit is contained in:
Taranto 2020-10-11 18:04:46 +01:00 committed by Josh Harvey
parent 0f4350f99c
commit 3a6f3a2915
40 changed files with 12622 additions and 9244 deletions

View file

@ -0,0 +1,21 @@
import * as R from 'ramda'
import schema from 'src/pages/Services/schemas'
const contains = crypto => R.compose(R.contains(crypto), R.prop('cryptos'))
const sameClass = type => R.propEq('class', type)
const filterConfig = (crypto, type) =>
R.filter(it => sameClass(type)(it) && contains(crypto)(it))
export const getItems = (accountsConfig, accounts, type, crypto) => {
const fConfig = filterConfig(crypto, type)(accountsConfig)
const find = code => accounts && accounts[code]
const [filled, unfilled] = R.partition(({ code }) => {
const account = find(code)
if (!schema[code]) return true
const { validationSchema } = schema[code]
return validationSchema.isValidSync(account)
})(fConfig)
return { filled, unfilled }
}