lamassu-server/lib/new-admin/machines.js
chaotixkilla 26c5c427bf Reintroduce cashbox (#535)
* feat: reintroduce cashbox component

* feat: cashbox update on db

* feat: cashbox on notifications

* feat: cashbox on overrides

* fix: cashin notifications

* fix: styling

* feat: cashin bills added to cashbox

* refactor: comment unused code

* fix: new bills length on cashbox

* fix: remove unused code

* chore: remove temporary code
2021-01-18 20:23:46 +00:00

19 lines
707 B
JavaScript

const machineLoader = require('../machine-loader')
const { UserInputError } = require('apollo-server-express')
function getMachine (machineId) {
return machineLoader.getMachines()
.then(machines => machines.find(({ deviceId }) => deviceId === machineId))
}
function machineAction ({ deviceId, action, cashbox, cassette1, cassette2, newName }) {
return getMachine(deviceId)
.then(machine => {
if (!machine) throw new UserInputError(`machine:${deviceId} not found`, { deviceId })
return machine
})
.then(machineLoader.setMachine({ deviceId, action, cashbox, cassettes: [cassette1, cassette2], newName }))
.then(getMachine(deviceId))
}
module.exports = { machineAction }