From 655fb3805911a0d4453e679d06da3c00f1f3a361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Fri, 18 Feb 2022 00:19:02 +0000 Subject: [PATCH] fix: receipt options saved as strings --- .../booleanPropertiesTable/BooleanPropertiesTable.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/new-lamassu-admin/src/components/booleanPropertiesTable/BooleanPropertiesTable.js b/new-lamassu-admin/src/components/booleanPropertiesTable/BooleanPropertiesTable.js index 7964643b..5358bae2 100644 --- a/new-lamassu-admin/src/components/booleanPropertiesTable/BooleanPropertiesTable.js +++ b/new-lamassu-admin/src/components/booleanPropertiesTable/BooleanPropertiesTable.js @@ -27,7 +27,7 @@ const BooleanCell = ({ name }) => { const BooleanPropertiesTable = memo( ({ title, disabled, data, elements, save, forcedEditing = false }) => { const initialValues = R.fromPairs( - elements.map(it => [it.name, data[it.name] ?? null]) + elements.map(it => [it.name, data[it.name].toString() ?? null]) ) const schemaValidation = R.fromPairs( @@ -38,8 +38,9 @@ const BooleanPropertiesTable = memo( const classes = useStyles() - const innerSave = async value => { - save(R.filter(R.complement(R.isNil), value)) + const innerSave = async values => { + const toBoolean = (num, _) => R.equals(num, 'true') + save(R.mapObjIndexed(toBoolean, R.filter(R.complement(R.isNil))(values))) setEditing(false) }