fix: verify if total in cassettes is NaN
This commit is contained in:
parent
05b65fe7f0
commit
1595f4f60e
2 changed files with 5 additions and 5 deletions
|
|
@ -7,6 +7,7 @@ import { Info1, Info2, Info3 } from 'src/components/typography/index'
|
||||||
// import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.svg'
|
// import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.svg'
|
||||||
import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg'
|
import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg'
|
||||||
import { fromNamespace } from 'src/utils/config'
|
import { fromNamespace } from 'src/utils/config'
|
||||||
|
import { isValidNumber } from 'src/utils/number'
|
||||||
|
|
||||||
import styles from './CashCassettesFooter.styles.js'
|
import styles from './CashCassettesFooter.styles.js'
|
||||||
const useStyles = makeStyles(styles)
|
const useStyles = makeStyles(styles)
|
||||||
|
|
@ -29,9 +30,7 @@ const CashCassettesFooter = ({
|
||||||
(acc[0] += cassette1 * getCashoutSettings(id).top),
|
(acc[0] += cassette1 * getCashoutSettings(id).top),
|
||||||
(acc[1] += cassette2 * getCashoutSettings(id).bottom)
|
(acc[1] += cassette2 * getCashoutSettings(id).bottom)
|
||||||
]
|
]
|
||||||
const totalInCassettes = R.isEmpty(machines)
|
const totalInCassettes = R.sum(R.reduce(reducerFn, [0, 0], machines))
|
||||||
? 0
|
|
||||||
: R.sum(R.reduce(reducerFn, [0, 0], machines))
|
|
||||||
|
|
||||||
/* const totalInCashBox = R.sum(
|
/* const totalInCashBox = R.sum(
|
||||||
R.flatten(
|
R.flatten(
|
||||||
|
|
@ -62,7 +61,8 @@ const CashCassettesFooter = ({
|
||||||
<TxOutIcon className={classes.icon} />
|
<TxOutIcon className={classes.icon} />
|
||||||
<Info2 className={classes.iconLabel}>Cash-out:</Info2>
|
<Info2 className={classes.iconLabel}>Cash-out:</Info2>
|
||||||
<Info1 className={classes.valueDisplay}>
|
<Info1 className={classes.valueDisplay}>
|
||||||
{totalInCassettes} {currencyCode}
|
{isValidNumber(totalInCassettes) ? totalInCassettes : 0}{' '}
|
||||||
|
{currencyCode}
|
||||||
</Info1>
|
</Info1>
|
||||||
</div>
|
</div>
|
||||||
{/* <div className={classes.flex}>
|
{/* <div className={classes.flex}>
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,4 @@ const isValidNumber = R.both(R.is(Number), R.complement(R.equals(NaN)))
|
||||||
|
|
||||||
const transformNumber = value => (isValidNumber(value) ? value : null)
|
const transformNumber = value => (isValidNumber(value) ? value : null)
|
||||||
|
|
||||||
export { transformNumber }
|
export { transformNumber, isValidNumber }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue