refactor: simplify and cleanup front-end

This commit is contained in:
José Oliveira 2021-02-15 13:46:09 +00:00 committed by Josh Harvey
parent a8fbb57bf6
commit 351d2a078b
14 changed files with 93 additions and 213 deletions

View file

@ -58,21 +58,17 @@ const Services = () => {
}
const getElements = ({ code, elements }) => {
return R.compose(
R.map(elem => {
return elem.component === SecretInput
? R.assoc(
'inputProps',
{
isPasswordFilled:
!R.isNil(accounts[code]) &&
!R.isNil(R.path([elem.code], accounts[code]))
},
elem
)
: R.identity(elem)
})
)(elements)
return R.map(elem => {
if (elem.component !== SecretInput) return elem
return {
...elem,
inputProps: {
isPasswordFilled:
!R.isNil(accounts[code]) &&
!R.isNil(R.path([elem.code], accounts[code]))
}
}
}, elements)
}
const getAccounts = ({ elements, code }) => {
@ -81,22 +77,14 @@ const Services = () => {
R.reject(R.isNil),
R.map(({ component, code }) => (component === SecretInput ? code : null))
)(elements)
return R.compose(
R.mapObjIndexed((value, key, obj) =>
R.includes(key, passwordFields) ? '' : value
)
)(account)
return R.mapObjIndexed(
(value, key) => (R.includes(key, passwordFields) ? '' : value),
account
)
}
const getValidationSchema = ({
validationSchema,
code,
hasSecret,
getValidationSchema
}) => {
if (!hasSecret) return validationSchema
return getValidationSchema(accounts[code])
}
const getValidationSchema = ({ code, getValidationSchema }) =>
getValidationSchema(accounts[code])
return (
<div className={classes.wrapper}>