fix: verify if total in cassettes is NaN

This commit is contained in:
José Oliveira 2021-03-22 16:40:31 +00:00 committed by Josh Harvey
parent 8322b99f11
commit a1e8e8bc4c
2 changed files with 5 additions and 5 deletions

View file

@ -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 TxOutIcon } from 'src/styling/icons/direction/cash-out.svg'
import { fromNamespace } from 'src/utils/config'
import { isValidNumber } from 'src/utils/number'
import styles from './CashCassettesFooter.styles.js'
const useStyles = makeStyles(styles)
@ -29,9 +30,7 @@ const CashCassettesFooter = ({
(acc[0] += cassette1 * getCashoutSettings(id).top),
(acc[1] += cassette2 * getCashoutSettings(id).bottom)
]
const totalInCassettes = R.isEmpty(machines)
? 0
: R.sum(R.reduce(reducerFn, [0, 0], machines))
const totalInCassettes = R.sum(R.reduce(reducerFn, [0, 0], machines))
/* const totalInCashBox = R.sum(
R.flatten(
@ -62,7 +61,8 @@ const CashCassettesFooter = ({
<TxOutIcon className={classes.icon} />
<Info2 className={classes.iconLabel}>Cash-out:</Info2>
<Info1 className={classes.valueDisplay}>
{totalInCassettes} {currencyCode}
{isValidNumber(totalInCassettes) ? totalInCassettes : 0}{' '}
{currencyCode}
</Info1>
</div>
{/* <div className={classes.flex}>

View file

@ -4,4 +4,4 @@ const isValidNumber = R.both(R.is(Number), R.complement(R.equals(NaN)))
const transformNumber = value => (isValidNumber(value) ? value : null)
export { transformNumber }
export { transformNumber, isValidNumber }