fix: multiple edit fields
This commit is contained in:
parent
d292ea4ae3
commit
2ecc079cb3
1 changed files with 6 additions and 21 deletions
|
|
@ -72,7 +72,7 @@ const useStyles = makeStyles(styles)
|
||||||
const CashboxHistory = ({ machines, currency }) => {
|
const CashboxHistory = ({ machines, currency }) => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const [error, setError] = useState(false)
|
const [error, setError] = useState(false)
|
||||||
const [fields, setFields] = useState([])
|
const [field, setField] = useState(null)
|
||||||
|
|
||||||
const { data: batchesData, loading: batchesLoading } = useQuery(GET_BATCHES)
|
const { data: batchesData, loading: batchesLoading } = useQuery(GET_BATCHES)
|
||||||
|
|
||||||
|
|
@ -117,7 +117,6 @@ const CashboxHistory = ({ machines, currency }) => {
|
||||||
)
|
)
|
||||||
|
|
||||||
const save = row => {
|
const save = row => {
|
||||||
const field = R.find(f => f.id === row.id, fields)
|
|
||||||
const performedBy = field.performedBy === '' ? null : field.performedBy
|
const performedBy = field.performedBy === '' ? null : field.performedBy
|
||||||
|
|
||||||
schema
|
schema
|
||||||
|
|
@ -133,10 +132,10 @@ const CashboxHistory = ({ machines, currency }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const close = id => {
|
const close = id => {
|
||||||
setFields(R.filter(f => f.id !== id, fields))
|
setField(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
const notEditing = id => !R.any(R.propEq('id', id), fields)
|
const notEditing = id => field?.id !== id
|
||||||
|
|
||||||
const elements = [
|
const elements = [
|
||||||
{
|
{
|
||||||
|
|
@ -206,21 +205,10 @@ const CashboxHistory = ({ machines, currency }) => {
|
||||||
return R.isNil(it.performedBy) ? 'Unknown entity' : it.performedBy
|
return R.isNil(it.performedBy) ? 'Unknown entity' : it.performedBy
|
||||||
return (
|
return (
|
||||||
<TextInput
|
<TextInput
|
||||||
onChange={e =>
|
onChange={e => setField({ ...field, performedBy: e.target.value })}
|
||||||
setFields(
|
|
||||||
R.map(
|
|
||||||
f =>
|
|
||||||
f.id === it.id ? { ...f, performedBy: e.target.value } : f,
|
|
||||||
fields
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
error={error}
|
error={error}
|
||||||
width={190 * 0.85}
|
width={190 * 0.85}
|
||||||
value={R.prop(
|
value={field?.performedBy}
|
||||||
'performedBy',
|
|
||||||
R.find(f => f.id === it.id, fields)
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -235,10 +223,7 @@ const CashboxHistory = ({ machines, currency }) => {
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setFields([
|
setField({ id: it.id, performedBy: it.performedBy })
|
||||||
...fields,
|
|
||||||
{ id: it.id, performedBy: it.performedBy }
|
|
||||||
])
|
|
||||||
}}>
|
}}>
|
||||||
<EditIcon />
|
<EditIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue