fix: wasCashboxEmptied depends on state

refactor: `wasCashboxEmptied` and `cashbox` moved to the if block
This commit is contained in:
Nikola Ubavic 2021-10-22 14:02:36 +02:00
parent ff474ee507
commit 3b5fb01a20

View file

@ -38,12 +38,16 @@ const Wizard = ({ machine, cashoutSettings, locale, onClose, save, error }) => {
const isLastStep = step === LAST_STEP
const onContinue = it => {
const wasCashboxEmptied = it?.wasCashboxEmptied === 'YES'
const cashbox = wasCashboxEmptied ? 0 : machine?.cashbox
const newConfig = R.merge(config, it)
if (isLastStep) {
const wasCashboxEmptied = [
config?.wasCashboxEmptied,
it?.wasCashboxEmptied
].includes('YES')
const cashbox = wasCashboxEmptied ? 0 : machine?.cashbox
if (wasCashboxEmptied) {
createBatch({
variables: {