feat: replace toggle with radio and option descriptions
This commit is contained in:
parent
b5c37442c3
commit
c83b3cda56
4 changed files with 81 additions and 27 deletions
|
|
@ -14,7 +14,7 @@ function notifyCashboxRemoval (req, res, next) {
|
||||||
.then(async config => {
|
.then(async config => {
|
||||||
console.log('entered the config')
|
console.log('entered the config')
|
||||||
const cashInSettings = getCashInSettings(config)
|
const cashInSettings = getCashInSettings(config)
|
||||||
if (cashInSettings.automaticCashboxReset) {
|
if (cashInSettings.cashboxReset === 'Automatic') {
|
||||||
console.log('We proceed with the cashbox reset!!')
|
console.log('We proceed with the cashbox reset!!')
|
||||||
await cashbox.createCashboxBatch(req.deviceId, machine.cashbox)
|
await cashbox.createCashboxBatch(req.deviceId, machine.cashbox)
|
||||||
await machine.setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' })
|
await machine.setMachine({ deviceId: req.deviceId, action: 'emptyCashInBills' })
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const { saveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
const newConfig = {
|
const newConfig = {
|
||||||
cashIn_automaticCashboxReset: false
|
cashIn_cashboxReset: 'Manual'
|
||||||
}
|
}
|
||||||
return loadLatest()
|
return loadLatest()
|
||||||
.then(config => {
|
.then(config => {
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
import { useQuery, useMutation } from '@apollo/react-hooks'
|
import { useQuery, useMutation } from '@apollo/react-hooks'
|
||||||
import { makeStyles, Box } from '@material-ui/core'
|
import { DialogActions, makeStyles, Box } from '@material-ui/core'
|
||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
import * as R from 'ramda'
|
import * as R from 'ramda'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import * as Yup from 'yup'
|
import * as Yup from 'yup'
|
||||||
|
|
||||||
import { Tooltip } from 'src/components/Tooltip'
|
import Modal from 'src/components/Modal'
|
||||||
import { IconButton } from 'src/components/buttons'
|
import { IconButton, Button } from 'src/components/buttons'
|
||||||
import { Table as EditableTable } from 'src/components/editableTable'
|
import { Table as EditableTable } from 'src/components/editableTable'
|
||||||
import { Switch } from 'src/components/inputs'
|
import { RadioGroup } from 'src/components/inputs'
|
||||||
import { CashOut, CashIn } from 'src/components/inputs/cashbox/Cashbox'
|
import { CashOut, CashIn } from 'src/components/inputs/cashbox/Cashbox'
|
||||||
import { NumberInput, CashCassetteInput } 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 { P, Label2 } from 'src/components/typography'
|
import { P } from 'src/components/typography'
|
||||||
import { ReactComponent as EditIcon } from 'src/styling/icons/action/edit/enabled.svg'
|
import { ReactComponent as EditIcon } from 'src/styling/icons/action/edit/enabled.svg'
|
||||||
import { ReactComponent as ReverseHistoryIcon } from 'src/styling/icons/circle buttons/history/white.svg'
|
import { ReactComponent as ReverseHistoryIcon } from 'src/styling/icons/circle buttons/history/white.svg'
|
||||||
import { ReactComponent as HistoryIcon } from 'src/styling/icons/circle buttons/history/zodiac.svg'
|
import { ReactComponent as HistoryIcon } from 'src/styling/icons/circle buttons/history/zodiac.svg'
|
||||||
|
|
@ -102,6 +102,8 @@ const SET_CASSETTE_BILLS = gql`
|
||||||
const CashCassettes = () => {
|
const CashCassettes = () => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const [showHistory, setShowHistory] = useState(false)
|
const [showHistory, setShowHistory] = useState(false)
|
||||||
|
const [editingSchema, setEditingSchema] = useState(null)
|
||||||
|
const [selectedRadio, setSelectedRadio] = useState(null)
|
||||||
|
|
||||||
const { data } = useQuery(GET_MACHINES_AND_CONFIG)
|
const { data } = useQuery(GET_MACHINES_AND_CONFIG)
|
||||||
const [wizard, setWizard] = useState(false)
|
const [wizard, setWizard] = useState(false)
|
||||||
|
|
@ -113,9 +115,10 @@ const CashCassettes = () => {
|
||||||
refetchQueries: () => ['getData']
|
refetchQueries: () => ['getData']
|
||||||
})
|
})
|
||||||
const [saveConfig] = useMutation(SAVE_CONFIG, {
|
const [saveConfig] = useMutation(SAVE_CONFIG, {
|
||||||
onCompleted: () => setWizard(false),
|
onCompleted: () => setEditingSchema(false),
|
||||||
refetchQueries: () => ['getData']
|
refetchQueries: () => ['getData']
|
||||||
})
|
})
|
||||||
|
|
||||||
const bills = R.groupBy(bill => bill.deviceId)(R.path(['bills'])(data) ?? [])
|
const bills = R.groupBy(bill => bill.deviceId)(R.path(['bills'])(data) ?? [])
|
||||||
const deviceIds = R.uniq(
|
const deviceIds = R.uniq(
|
||||||
R.map(R.prop('deviceId'))(R.path(['bills'])(data) ?? [])
|
R.map(R.prop('deviceId'))(R.path(['bills'])(data) ?? [])
|
||||||
|
|
@ -124,15 +127,20 @@ const CashCassettes = () => {
|
||||||
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 cashInConfig = data?.config && fromNamespace('cashIn')(data.config)
|
const cashboxReset =
|
||||||
const automaticCashboxReset =
|
data?.config && fromNamespace('cashIn')(data.config).cashboxReset
|
||||||
R.path(['automaticCashboxReset'])(cashInConfig) ?? false
|
|
||||||
|
|
||||||
const cashboxResetSave = rawConfig => {
|
const cashboxResetSave = rawConfig => {
|
||||||
const config = toNamespace('cashIn')(rawConfig)
|
const config = toNamespace('cashIn')(rawConfig)
|
||||||
return saveConfig({ variables: { config } })
|
return saveConfig({ variables: { config } })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const saveCashboxOption = selection => {
|
||||||
|
if (selection) {
|
||||||
|
cashboxResetSave({ cashboxReset: selection })
|
||||||
|
setEditingSchema(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
const onSave = (id, cashbox, cassette1, cassette2) => {
|
const onSave = (id, cashbox, cassette1, cassette2) => {
|
||||||
return setCassetteBills({
|
return setCassetteBills({
|
||||||
variables: {
|
variables: {
|
||||||
|
|
@ -147,6 +155,16 @@ const CashCassettes = () => {
|
||||||
const getCashoutSettings = id => fromNamespace(id)(cashout)
|
const getCashoutSettings = id => fromNamespace(id)(cashout)
|
||||||
const isCashOutDisabled = ({ id }) => !getCashoutSettings(id).active
|
const isCashOutDisabled = ({ id }) => !getCashoutSettings(id).active
|
||||||
|
|
||||||
|
const radioButtonOptions = [
|
||||||
|
{ display: 'Automatic', code: 'Automatic' },
|
||||||
|
{ display: 'Manual', code: 'Manual' }
|
||||||
|
]
|
||||||
|
|
||||||
|
const handleRadioButtons = evt => {
|
||||||
|
const selectedRadio = R.path(['target', 'value'])(evt)
|
||||||
|
setSelectedRadio(selectedRadio)
|
||||||
|
}
|
||||||
|
|
||||||
const elements = [
|
const elements = [
|
||||||
{
|
{
|
||||||
name: 'name',
|
name: 'name',
|
||||||
|
|
@ -236,28 +254,19 @@ const CashCassettes = () => {
|
||||||
}}
|
}}
|
||||||
iconClassName={classes.listViewButton}
|
iconClassName={classes.listViewButton}
|
||||||
className={classes.tableWidth}>
|
className={classes.tableWidth}>
|
||||||
|
<P className={classes.descriptions}>Cashbox reset</P>
|
||||||
<Box display="flex" alignItems="center">
|
<Box display="flex" alignItems="center">
|
||||||
<Box
|
<Box
|
||||||
display="flex"
|
display="flex"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
justifyContent="end"
|
justifyContent="end"
|
||||||
mr="-5px">
|
mr="-5px">
|
||||||
<P>Set automatic cashbox reset</P>
|
<P>{cashboxReset}</P>
|
||||||
<Switch
|
<IconButton
|
||||||
checked={automaticCashboxReset}
|
onClick={() => setEditingSchema(true)}
|
||||||
onChange={event => {
|
className={classes.button}>
|
||||||
cashboxResetSave({
|
<EditIcon />
|
||||||
automaticCashboxReset: event.target.checked
|
</IconButton>
|
||||||
})
|
|
||||||
}}
|
|
||||||
value={automaticCashboxReset}
|
|
||||||
/>
|
|
||||||
<Label2 className={classes.switchLabel}>
|
|
||||||
{automaticCashboxReset ? 'Automatic' : 'Manual'}
|
|
||||||
</Label2>
|
|
||||||
<Tooltip width={304}>
|
|
||||||
<P>Tooltip text</P>
|
|
||||||
</Tooltip>
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</TitleSection>
|
</TitleSection>
|
||||||
|
|
@ -303,6 +312,46 @@ const CashCassettes = () => {
|
||||||
locale={locale}
|
locale={locale}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{editingSchema && (
|
||||||
|
<Modal
|
||||||
|
title={'Cashbox reset'}
|
||||||
|
width={478}
|
||||||
|
handleClose={() => setEditingSchema(null)}
|
||||||
|
open={true}>
|
||||||
|
<P className={classes.descriptions}>
|
||||||
|
Specify if you want your cash-in counts to be reset automatically or
|
||||||
|
manually.
|
||||||
|
</P>
|
||||||
|
<RadioGroup
|
||||||
|
name="set-automatic-reset"
|
||||||
|
value={selectedRadio}
|
||||||
|
options={[radioButtonOptions[0]]}
|
||||||
|
onChange={handleRadioButtons}
|
||||||
|
className={classes.radioButtons}
|
||||||
|
/>
|
||||||
|
<P className={classes.descriptions}>
|
||||||
|
Choose this option if you want your cash-in cashbox count to be
|
||||||
|
automatically when it is physically removed from the machine.
|
||||||
|
</P>
|
||||||
|
<RadioGroup
|
||||||
|
name="set-manual-reset"
|
||||||
|
value={selectedRadio}
|
||||||
|
options={[radioButtonOptions[1]]}
|
||||||
|
onChange={handleRadioButtons}
|
||||||
|
className={classes.radioButtons}
|
||||||
|
/>
|
||||||
|
<P className={classes.descriptions}>
|
||||||
|
Choose this option if you want to edit your cash-in counts manually
|
||||||
|
on Lamassu Admin, after you physically remove the bills from the
|
||||||
|
cashbox.
|
||||||
|
</P>
|
||||||
|
<DialogActions className={classes.actions}>
|
||||||
|
<Button onClick={() => saveCashboxOption(selectedRadio)}>
|
||||||
|
Confirm
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Modal>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { offColor } from 'src/styling/variables'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
cashbox: {
|
cashbox: {
|
||||||
width: 80,
|
width: 80,
|
||||||
|
|
@ -15,5 +17,8 @@ export default {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
marginRight: 90
|
marginRight: 90
|
||||||
|
},
|
||||||
|
descriptions: {
|
||||||
|
color: offColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue