import { makeStyles } from '@material-ui/core/styles' import classnames from 'classnames' import React from 'react' import Chip from 'src/components/Chip' import { Link } from 'src/components/buttons' import { Info2, Label1, Label2 } from 'src/components/typography' import TextInputFormik from '../base/TextInput' import { cashboxStyles, gridStyles } from './Cashbox.styles' const cashboxClasses = makeStyles(cashboxStyles) const gridClasses = makeStyles(gridStyles) const Cashbox = ({ percent = 0, cashOut = false, className, emptyPartClassName, labelClassName, applyColorVariant, applyFiatBalanceAlertsStyling, removeInnerPercentage }) => { const classes = cashboxClasses({ percent, cashOut, applyColorVariant }) const threshold = 51 const showCashBox = { [classes.fiatBalanceAlertCashbox]: applyFiatBalanceAlertsStyling, [classes.cashbox]: !applyFiatBalanceAlertsStyling } return (
{!removeInnerPercentage && percent <= threshold && ( {percent.toFixed(0)}% )}
{!removeInnerPercentage && percent > threshold && ( {percent.toFixed(0)}% )}
) } // https://support.lamassu.is/hc/en-us/articles/360025595552-Installing-the-Sintra-Forte // Sintra and Sintra Forte can have up to 500 notes per cashOut box and up to 1000 per cashIn box const CashIn = ({ currency, notes, total }) => { const classes = gridClasses() return ( <>
{notes} notes
{/* Feature on hold until this can be calculated {total} {currency.code} */}
) } const CashInFormik = ({ capacity = 1000, onEmpty, field: { value: { notes, deviceId } }, form: { setFieldValue } }) => { const classes = gridClasses() return ( <>
{ onEmpty({ variables: { deviceId, action: 'emptyCashInBills' } }).then(() => setFieldValue('cashin.notes', 0)) }} className={classes.link} color={'primary'}> Empty
) } const CashOut = ({ capacity = 500, denomination = 0, currency, notes, className, editingMode = false }) => { const percent = (100 * notes) / capacity const classes = gridClasses() return ( <>
{!editingMode && (
{notes}
{notes * denomination} {currency.code}
)}
) } const CashOutFormik = ({ capacity = 500, ...props }) => { const { name, onChange, onBlur, value: { notes } } = props.field const { touched, errors } = props.form const error = !!(touched[name] && errors[name]) const percent = (100 * notes) / capacity const classes = gridClasses() return ( <>
) } export { Cashbox, CashIn, CashInFormik, CashOut, CashOutFormik }