Feat: cash cassette graph next to input field
This commit is contained in:
parent
1ffbffd0be
commit
60894347d8
6 changed files with 90 additions and 34 deletions
|
|
@ -46,7 +46,7 @@ const CashIn = ({ currency, notes, total }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={classes.row}>
|
<div className={classes.row}>
|
||||||
<div className={classes.col2}>
|
<div>
|
||||||
<div className={classes.innerRow}>
|
<div className={classes.innerRow}>
|
||||||
<Info2 className={classes.noMarginText}>{notes} notes</Info2>
|
<Info2 className={classes.noMarginText}>{notes} notes</Info2>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -104,7 +104,8 @@ const CashOut = ({
|
||||||
denomination = 0,
|
denomination = 0,
|
||||||
currency,
|
currency,
|
||||||
notes,
|
notes,
|
||||||
className
|
className,
|
||||||
|
editingMode = false
|
||||||
}) => {
|
}) => {
|
||||||
const percent = (100 * notes) / capacity
|
const percent = (100 * notes) / capacity
|
||||||
const classes = gridClasses()
|
const classes = gridClasses()
|
||||||
|
|
@ -114,20 +115,22 @@ const CashOut = ({
|
||||||
<div className={classes.col}>
|
<div className={classes.col}>
|
||||||
<Cashbox className={className} percent={percent} cashOut />
|
<Cashbox className={className} percent={percent} cashOut />
|
||||||
</div>
|
</div>
|
||||||
<div className={classes.col2}>
|
{!editingMode && (
|
||||||
<div className={classes.innerRow}>
|
<div className={classes.col2}>
|
||||||
<Info2 className={classes.noMarginText}>{notes}</Info2>
|
<div className={classes.innerRow}>
|
||||||
<Chip
|
<Info2 className={classes.noMarginText}>{notes}</Info2>
|
||||||
className={classes.chip}
|
<Chip
|
||||||
label={`${denomination} ${currency.code}`}
|
className={classes.chip}
|
||||||
/>
|
label={`${denomination} ${currency.code}`}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className={classes.innerRow}>
|
||||||
|
<Label1 className={classes.noMarginText}>
|
||||||
|
{notes * denomination} {currency.code}
|
||||||
|
</Label1>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={classes.innerRow}>
|
)}
|
||||||
<Label1 className={classes.noMarginText}>
|
|
||||||
{notes * denomination} {currency.code}
|
|
||||||
</Label1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,7 @@ const cashboxStyles = {
|
||||||
|
|
||||||
const gridStyles = {
|
const gridStyles = {
|
||||||
row: {
|
row: {
|
||||||
display: 'flex',
|
display: 'flex'
|
||||||
justifyContent: 'space-between'
|
|
||||||
},
|
},
|
||||||
innerRow: {
|
innerRow: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
import { makeStyles } from '@material-ui/core'
|
||||||
|
import React, { memo, useState } from 'react'
|
||||||
|
|
||||||
|
import { CashOut } from 'src/components/inputs/cashbox/Cashbox'
|
||||||
|
|
||||||
|
import { NumberInput } from '../base'
|
||||||
|
const useStyles = makeStyles({
|
||||||
|
flex: {
|
||||||
|
display: 'flex'
|
||||||
|
},
|
||||||
|
cashCassette: {
|
||||||
|
width: 80,
|
||||||
|
height: 36,
|
||||||
|
marginRight: 16
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const CashCassetteInput = memo(({ decimalPlaces, ...props }) => {
|
||||||
|
const classes = useStyles()
|
||||||
|
const { name, onChange, onBlur, value } = props.field
|
||||||
|
const { touched, errors } = props.form
|
||||||
|
const [notes, setNotes] = useState(value)
|
||||||
|
const error = !!(touched[name] && errors[name])
|
||||||
|
return (
|
||||||
|
<div className={classes.flex}>
|
||||||
|
<CashOut
|
||||||
|
className={classes.cashCassette}
|
||||||
|
notes={notes}
|
||||||
|
editingMode={true}
|
||||||
|
/>
|
||||||
|
<NumberInput
|
||||||
|
name={name}
|
||||||
|
onChange={e => {
|
||||||
|
setNotes(e.target.value)
|
||||||
|
return onChange(e)
|
||||||
|
}}
|
||||||
|
onBlur={onBlur}
|
||||||
|
value={value}
|
||||||
|
error={error}
|
||||||
|
decimalPlaces={decimalPlaces}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
export default CashCassetteInput
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import Autocomplete from './Autocomplete'
|
import Autocomplete from './Autocomplete'
|
||||||
|
import CashCassetteInput from './CashCassetteInput'
|
||||||
import Checkbox from './Checkbox'
|
import Checkbox from './Checkbox'
|
||||||
import NumberInput from './NumberInput'
|
import NumberInput from './NumberInput'
|
||||||
import RadioGroup from './RadioGroup'
|
import RadioGroup from './RadioGroup'
|
||||||
|
|
@ -11,5 +12,6 @@ export {
|
||||||
TextInput,
|
TextInput,
|
||||||
NumberInput,
|
NumberInput,
|
||||||
SecretInput,
|
SecretInput,
|
||||||
RadioGroup
|
RadioGroup,
|
||||||
|
CashCassetteInput
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import * as Yup from 'yup'
|
||||||
|
|
||||||
import { Table as EditableTable } from 'src/components/editableTable'
|
import { Table as EditableTable } from 'src/components/editableTable'
|
||||||
import { CashOut, CashIn } from 'src/components/inputs/cashbox/Cashbox'
|
import { CashOut, CashIn } from 'src/components/inputs/cashbox/Cashbox'
|
||||||
import { NumberInput } from 'src/components/inputs/formik'
|
import { NumberInput, CashCassetteInput } from 'src/components/inputs/formik'
|
||||||
import TitleSection from 'src/components/layout/TitleSection'
|
import TitleSection from 'src/components/layout/TitleSection'
|
||||||
import { EmptyTable } from 'src/components/table'
|
import { EmptyTable } from 'src/components/table'
|
||||||
import { fromNamespace } from 'src/utils/config'
|
import { fromNamespace } from 'src/utils/config'
|
||||||
|
|
@ -86,6 +86,7 @@ const CashCassettes = () => {
|
||||||
const cashout = data?.config && fromNamespace('cashOut')(data.config)
|
const cashout = data?.config && fromNamespace('cashOut')(data.config)
|
||||||
const locale = data?.config && fromNamespace('locale')(data.config)
|
const locale = data?.config && fromNamespace('locale')(data.config)
|
||||||
const fiatCurrency = locale?.fiatCurrency
|
const fiatCurrency = locale?.fiatCurrency
|
||||||
|
const machines = R.path(['machines'])(data) ?? []
|
||||||
|
|
||||||
const onSave = (...[, { id, cashbox, cassette1, cassette2 }]) => {
|
const onSave = (...[, { id, cashbox, cassette1, cassette2 }]) => {
|
||||||
return setCassetteBills({
|
return setCassetteBills({
|
||||||
|
|
@ -135,7 +136,7 @@ const CashCassettes = () => {
|
||||||
notes={value}
|
notes={value}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
input: NumberInput,
|
input: CashCassetteInput,
|
||||||
inputProps: {
|
inputProps: {
|
||||||
decimalPlaces: 0
|
decimalPlaces: 0
|
||||||
}
|
}
|
||||||
|
|
@ -145,15 +146,17 @@ const CashCassettes = () => {
|
||||||
header: 'Cassette 2 (Bottom)',
|
header: 'Cassette 2 (Bottom)',
|
||||||
width: 265,
|
width: 265,
|
||||||
stripe: true,
|
stripe: true,
|
||||||
view: (value, { id }) => (
|
view: (value, { id }) => {
|
||||||
<CashOut
|
return (
|
||||||
className={classes.cashbox}
|
<CashOut
|
||||||
denomination={getCashoutSettings(id)?.bottom}
|
className={classes.cashbox}
|
||||||
currency={{ code: fiatCurrency }}
|
denomination={getCashoutSettings(id)?.bottom}
|
||||||
notes={value}
|
currency={{ code: fiatCurrency }}
|
||||||
/>
|
notes={value}
|
||||||
),
|
/>
|
||||||
input: NumberInput,
|
)
|
||||||
|
},
|
||||||
|
input: CashCassetteInput,
|
||||||
inputProps: {
|
inputProps: {
|
||||||
decimalPlaces: 0
|
decimalPlaces: 0
|
||||||
}
|
}
|
||||||
|
|
@ -161,24 +164,23 @@ const CashCassettes = () => {
|
||||||
]
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className={classes.pageBottomMargin}>
|
||||||
<TitleSection title="Cash Cassettes" />
|
<TitleSection title="Cash Cassettes" />
|
||||||
|
|
||||||
<EditableTable
|
<EditableTable
|
||||||
error={error?.message}
|
error={error?.message}
|
||||||
name="cashboxes"
|
name="cashboxes"
|
||||||
enableEdit
|
enableEdit
|
||||||
stripeWhen={isCashOutDisabled}
|
stripeWhen={isCashOutDisabled}
|
||||||
elements={elements}
|
elements={elements}
|
||||||
data={data && data.machines}
|
data={machines}
|
||||||
save={onSave}
|
save={onSave}
|
||||||
validationSchema={ValidationSchema}
|
validationSchema={ValidationSchema}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{data && R.isEmpty(data.machines) && (
|
{data && R.isEmpty(machines) && (
|
||||||
<EmptyTable message="No machines so far" />
|
<EmptyTable message="No machines so far" />
|
||||||
)}
|
)}
|
||||||
</>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,8 @@ export default {
|
||||||
cashbox: {
|
cashbox: {
|
||||||
width: 80,
|
width: 80,
|
||||||
height: 36
|
height: 36
|
||||||
|
},
|
||||||
|
pageBottomMargin: {
|
||||||
|
marginBottom: 180
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue