fix: validation
chore: create `notEditing` function
This commit is contained in:
parent
c7996de4f2
commit
784c4c3ab1
1 changed files with 7 additions and 9 deletions
|
|
@ -110,15 +110,11 @@ const CashboxHistory = ({ machines, currency }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const save = row => {
|
const save = row => {
|
||||||
const _performedBy = R.prop(
|
const field = R.find(f => f.id === row.id, fields)
|
||||||
'performedBy',
|
const performedBy = field.performedBy === '' ? null : field.performedBy
|
||||||
R.find(f => f.id === row.id, fields)
|
|
||||||
)
|
|
||||||
|
|
||||||
const performedBy = _performedBy === '' ? null : _performedBy
|
|
||||||
|
|
||||||
schema
|
schema
|
||||||
.isValid(performedBy)
|
.isValid(field)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setError(false)
|
setError(false)
|
||||||
editBatch({
|
editBatch({
|
||||||
|
|
@ -133,6 +129,8 @@ const CashboxHistory = ({ machines, currency }) => {
|
||||||
setFields(R.filter(f => f.id !== id, fields))
|
setFields(R.filter(f => f.id !== id, fields))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const notEditing = id => !R.any(R.propEq('id', id), fields)
|
||||||
|
|
||||||
const elements = [
|
const elements = [
|
||||||
{
|
{
|
||||||
name: 'operation',
|
name: 'operation',
|
||||||
|
|
@ -197,7 +195,7 @@ const CashboxHistory = ({ machines, currency }) => {
|
||||||
width: 180,
|
width: 180,
|
||||||
textAlign: 'left',
|
textAlign: 'left',
|
||||||
view: it => {
|
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 R.isNil(it.performedBy) ? 'Unknown entity' : it.performedBy
|
||||||
return (
|
return (
|
||||||
<TextInput
|
<TextInput
|
||||||
|
|
@ -226,7 +224,7 @@ const CashboxHistory = ({ machines, currency }) => {
|
||||||
width: 150,
|
width: 150,
|
||||||
textAlign: 'right',
|
textAlign: 'right',
|
||||||
view: it => {
|
view: it => {
|
||||||
if (!R.any(R.propEq('id', it.id), fields))
|
if (notEditing(it.id))
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue