refactor: concat instead of push
This commit is contained in:
parent
749cbfbb2a
commit
c63dbf438d
1 changed files with 33 additions and 36 deletions
|
|
@ -51,7 +51,7 @@ const FiatBalanceOverrides = ({ config, section }) => {
|
||||||
const suggestions = suggestionFilter(machines)
|
const suggestions = suggestionFilter(machines)
|
||||||
|
|
||||||
const findSuggestion = it => {
|
const findSuggestion = it => {
|
||||||
const coin = R.compose(R.find(R.propEq('deviceId', it?.machine)))(machines)
|
const coin = R.find(R.propEq('deviceId', it?.machine), machines)
|
||||||
return coin ? [coin] : []
|
return coin ? [coin] : []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,37 +130,35 @@ const FiatBalanceOverrides = ({ config, section }) => {
|
||||||
const viewMachine = it =>
|
const viewMachine = it =>
|
||||||
R.compose(R.path(['name']), R.find(R.propEq('deviceId', it)))(machines)
|
R.compose(R.path(['name']), R.find(R.propEq('deviceId', it)))(machines)
|
||||||
|
|
||||||
const elements = [
|
const elements = R.concat(
|
||||||
{
|
[
|
||||||
name: MACHINE_KEY,
|
{
|
||||||
width: widthsByNumberOfCassettes[maxNumberOfCassettes].machine,
|
name: MACHINE_KEY,
|
||||||
size: 'sm',
|
width: widthsByNumberOfCassettes[maxNumberOfCassettes].machine,
|
||||||
view: viewMachine,
|
size: 'sm',
|
||||||
input: Autocomplete,
|
view: viewMachine,
|
||||||
inputProps: {
|
input: Autocomplete,
|
||||||
options: it => R.concat(suggestions, findSuggestion(it)),
|
inputProps: {
|
||||||
valueProp: 'deviceId',
|
options: it => R.concat(suggestions, findSuggestion(it)),
|
||||||
labelProp: 'name'
|
valueProp: 'deviceId',
|
||||||
|
labelProp: 'name'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: CASHBOX_KEY,
|
||||||
|
display: 'Cashbox',
|
||||||
|
width: 155,
|
||||||
|
textAlign: 'right',
|
||||||
|
bold: true,
|
||||||
|
input: NumberInput,
|
||||||
|
suffix: 'notes',
|
||||||
|
inputProps: {
|
||||||
|
decimalPlaces: 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
],
|
||||||
{
|
R.map(
|
||||||
name: CASHBOX_KEY,
|
it => ({
|
||||||
display: 'Cashbox',
|
|
||||||
width: 155,
|
|
||||||
textAlign: 'right',
|
|
||||||
bold: true,
|
|
||||||
input: NumberInput,
|
|
||||||
suffix: 'notes',
|
|
||||||
inputProps: {
|
|
||||||
decimalPlaces: 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
R.until(
|
|
||||||
R.gt(R.__, maxNumberOfCassettes),
|
|
||||||
it => {
|
|
||||||
elements.push({
|
|
||||||
name: `fillingPercentageCassette${it}`,
|
name: `fillingPercentageCassette${it}`,
|
||||||
display: `Cash cassette ${it}`,
|
display: `Cash cassette ${it}`,
|
||||||
width: widthsByNumberOfCassettes[maxNumberOfCassettes].cassette,
|
width: widthsByNumberOfCassettes[maxNumberOfCassettes].cassette,
|
||||||
|
|
@ -172,15 +170,14 @@ const FiatBalanceOverrides = ({ config, section }) => {
|
||||||
inputProps: {
|
inputProps: {
|
||||||
decimalPlaces: 0
|
decimalPlaces: 0
|
||||||
},
|
},
|
||||||
view: it => it?.toString() ?? '—',
|
view: el => el?.toString() ?? '—',
|
||||||
isHidden: value =>
|
isHidden: value =>
|
||||||
it >
|
it >
|
||||||
machines.find(({ deviceId }) => deviceId === value.machine)
|
machines.find(({ deviceId }) => deviceId === value.machine)
|
||||||
?.numberOfCassettes
|
?.numberOfCassettes
|
||||||
})
|
}),
|
||||||
return R.add(1, it)
|
R.range(1, maxNumberOfCassettes + 1)
|
||||||
},
|
)
|
||||||
1
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue