fix: add fallback for max number of cassettes calculations
This commit is contained in:
parent
b8517b3c19
commit
8dac871324
5 changed files with 15 additions and 10 deletions
|
|
@ -41,7 +41,8 @@ const DenominationsSchema = Yup.object().shape({
|
|||
const getElements = (machines, locale = {}, classes) => {
|
||||
const fiatCurrency = R.prop('fiatCurrency')(locale)
|
||||
const maxNumberOfCassettes = Math.max(
|
||||
...R.map(it => it.numberOfCassettes, machines)
|
||||
...R.map(it => it.numberOfCassettes, machines),
|
||||
0
|
||||
)
|
||||
|
||||
const options = getBillOptions(locale, denominations)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ const HeaderCell = withStyles({
|
|||
}
|
||||
})(TableCell)
|
||||
|
||||
const MachinesTable = ({ machines, numToRender }) => {
|
||||
const MachinesTable = ({ machines = [], numToRender }) => {
|
||||
const classes = useStyles()
|
||||
const history = useHistory()
|
||||
const getPercent = (notes, capacity = 500) => {
|
||||
|
|
@ -61,9 +61,10 @@ const MachinesTable = ({ machines, numToRender }) => {
|
|||
})
|
||||
}
|
||||
|
||||
const maxNumberOfCassettes = R.isEmpty(machines)
|
||||
? 0
|
||||
: Math.max(...R.map(it => it.numberOfCassettes, machines))
|
||||
const maxNumberOfCassettes = Math.max(
|
||||
...R.map(it => it.numberOfCassettes, machines),
|
||||
0
|
||||
)
|
||||
|
||||
return (
|
||||
<TableContainer className={classes.table}>
|
||||
|
|
|
|||
|
|
@ -160,7 +160,8 @@ const CashCassettes = () => {
|
|||
const locale = data?.config && fromNamespace('locale')(data.config)
|
||||
const fiatCurrency = locale?.fiatCurrency
|
||||
const maxNumberOfCassettes = Math.max(
|
||||
...R.map(it => it.numberOfCassettes, machines)
|
||||
...R.map(it => it.numberOfCassettes, machines),
|
||||
0
|
||||
)
|
||||
const cashboxCounts = R.reduce(
|
||||
(ret, m) => R.assoc(m.id, m.cashbox, ret),
|
||||
|
|
|
|||
|
|
@ -27,13 +27,14 @@ const FiatBalance = ({ section, min = 0, max = 100, fieldWidth = 80 }) => {
|
|||
setEditing,
|
||||
data,
|
||||
save,
|
||||
machines
|
||||
machines = []
|
||||
} = useContext(NotificationsCtx)
|
||||
const classes = useStyles()
|
||||
|
||||
const maxNumberOfCassettes =
|
||||
Math.max(...R.map(it => it.numberOfCassettes, machines)) ??
|
||||
const maxNumberOfCassettes = Math.max(
|
||||
...R.map(it => it.numberOfCassettes, machines),
|
||||
DEFAULT_NUMBER_OF_CASSETTES
|
||||
)
|
||||
|
||||
const editing = isEditing(NAME)
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ const FiatBalanceOverrides = ({ section }) => {
|
|||
}
|
||||
|
||||
const maxNumberOfCassettes = Math.max(
|
||||
...R.map(it => it.numberOfCassettes, machines)
|
||||
...R.map(it => it.numberOfCassettes, machines),
|
||||
0
|
||||
)
|
||||
|
||||
const percentMin = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue