From 784c4c3ab1bccb10144b9610a2ffb762ff64f063 Mon Sep 17 00:00:00 2001 From: Nikola Ubavic <53820106+ubavic@users.noreply.github.com> Date: Tue, 16 Nov 2021 22:57:11 +0100 Subject: [PATCH] fix: validation chore: create `notEditing` function --- .../src/pages/Maintenance/CashboxHistory.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/new-lamassu-admin/src/pages/Maintenance/CashboxHistory.js b/new-lamassu-admin/src/pages/Maintenance/CashboxHistory.js index 7e2cd8f4..1846bebe 100644 --- a/new-lamassu-admin/src/pages/Maintenance/CashboxHistory.js +++ b/new-lamassu-admin/src/pages/Maintenance/CashboxHistory.js @@ -110,15 +110,11 @@ const CashboxHistory = ({ machines, currency }) => { } const save = row => { - const _performedBy = R.prop( - 'performedBy', - R.find(f => f.id === row.id, fields) - ) - - const performedBy = _performedBy === '' ? null : _performedBy + const field = R.find(f => f.id === row.id, fields) + const performedBy = field.performedBy === '' ? null : field.performedBy schema - .isValid(performedBy) + .isValid(field) .then(() => { setError(false) editBatch({ @@ -133,6 +129,8 @@ const CashboxHistory = ({ machines, currency }) => { setFields(R.filter(f => f.id !== id, fields)) } + const notEditing = id => !R.any(R.propEq('id', id), fields) + const elements = [ { name: 'operation', @@ -197,7 +195,7 @@ const CashboxHistory = ({ machines, currency }) => { width: 180, textAlign: 'left', view: it => { - if (!R.any(R.propEq('id', it.id), fields)) + if (notEditing(it.id)) return R.isNil(it.performedBy) ? 'Unknown entity' : it.performedBy return ( { width: 150, textAlign: 'right', view: it => { - if (!R.any(R.propEq('id', it.id), fields)) + if (notEditing(it.id)) return ( {