From 122ffec9a005b7fe63dd4c018faf445cbee10740 Mon Sep 17 00:00:00 2001
From: hanfi <ccc@spahan.ch>
Date: Fri, 22 Sep 2023 21:26:21 +0200
Subject: [PATCH] allow adding by image

---
 dist/bundle.js    | 2 +-
 src/js/checkin.js | 8 +-------
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/dist/bundle.js b/dist/bundle.js
index baf1651..0082fa2 100644
--- a/dist/bundle.js
+++ b/dist/bundle.js
@@ -28,7 +28,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
 
 "use strict";
-eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   addItemByScan: () => (/* binding */ addItemByScan),\n/* harmony export */   addItemByTag: () => (/* binding */ addItemByTag),\n/* harmony export */   addItemImage: () => (/* binding */ addItemImage),\n/* harmony export */   checkinItem: () => (/* binding */ checkinItem)\n/* harmony export */ });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ \"./src/js/util.js\");\n/* harmony import */ var _auth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./auth */ \"./src/js/auth.js\");\n/* harmony import */ var _scanner__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./scanner */ \"./src/js/scanner.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = \"function\" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || \"@@iterator\", asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\", toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, \"\"); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, \"_invoke\", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: \"normal\", arg: fn.call(obj, arg) }; } catch (err) { return { type: \"throw\", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { [\"next\", \"throw\", \"return\"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if (\"throw\" !== record.type) { var result = record.arg, value = result.value; return value && \"object\" == _typeof(value) && hasOwn.call(value, \"__await\") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke(\"next\", value, resolve, reject); }, function (err) { invoke(\"throw\", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke(\"throw\", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, \"_invoke\", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = \"suspendedStart\"; return function (method, arg) { if (\"executing\" === state) throw new Error(\"Generator is already running\"); if (\"completed\" === state) { if (\"throw\" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if (\"next\" === context.method) context.sent = context._sent = context.arg;else if (\"throw\" === context.method) { if (\"suspendedStart\" === state) throw state = \"completed\", context.arg; context.dispatchException(context.arg); } else \"return\" === context.method && context.abrupt(\"return\", context.arg); state = \"executing\"; var record = tryCatch(innerFn, self, context); if (\"normal\" === record.type) { if (state = context.done ? \"completed\" : \"suspendedYield\", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } \"throw\" === record.type && (state = \"completed\", context.method = \"throw\", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, \"throw\" === methodName && delegate.iterator[\"return\"] && (context.method = \"return\", context.arg = undefined, maybeInvokeDelegate(delegate, context), \"throw\" === context.method) || \"return\" !== methodName && (context.method = \"throw\", context.arg = new TypeError(\"The iterator does not provide a '\" + methodName + \"' method\")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if (\"throw\" === record.type) return context.method = \"throw\", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, \"return\" !== context.method && (context.method = \"next\", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = \"throw\", context.arg = new TypeError(\"iterator result is not an object\"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = \"normal\", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: \"root\" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if (\"function\" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, \"GeneratorFunction\"), exports.isGeneratorFunction = function (genFun) { var ctor = \"function\" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || \"GeneratorFunction\" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, \"GeneratorFunction\")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, \"Generator\"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, \"toString\", function () { return \"[object Generator]\"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) \"t\" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if (\"throw\" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = \"throw\", record.arg = exception, context.next = loc, caught && (context.method = \"next\", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if (\"root\" === entry.tryLoc) return handle(\"end\"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, \"catchLoc\"), hasFinally = hasOwn.call(entry, \"finallyLoc\"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error(\"try statement without catch or finally\"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, \"finallyLoc\") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && (\"break\" === type || \"continue\" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = \"next\", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if (\"throw\" === record.type) throw record.arg; return \"break\" === record.type || \"continue\" === record.type ? this.next = record.arg : \"return\" === record.type ? (this.rval = this.arg = record.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, \"catch\": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if (\"throw\" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, \"next\" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\n\n\n\n/*\n * Add items by delivery tag\n */\nfunction addItemByTag(_x) {\n  return _addItemByTag.apply(this, arguments);\n}\n\n/*\n * add items scanned from qrcode\n */\nfunction _addItemByTag() {\n  _addItemByTag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(tag) {\n    var config, response, delivery;\n    return _regeneratorRuntime().wrap(function _callee$(_context) {\n      while (1) switch (_context.prev = _context.next) {\n        case 0:\n          console.log(\"Trying to add item by tag:\", tag);\n          _context.next = 3;\n          return (0,_util__WEBPACK_IMPORTED_MODULE_0__.getConfig)();\n        case 3:\n          config = _context.sent;\n          _context.next = 6;\n          return (0,_auth__WEBPACK_IMPORTED_MODULE_1__.fetchWithAuth)(config.backend_url + \"/tag/\" + tag);\n        case 6:\n          response = _context.sent;\n          if (!(response.status == 200)) {\n            _context.next = 17;\n            break;\n          }\n          _context.next = 10;\n          return response.json();\n        case 10:\n          delivery = _context.sent;\n          (0,_util__WEBPACK_IMPORTED_MODULE_0__.addToItemList)(delivery.uuid, \"\".concat(delivery.tag, \" (\").concat(delivery.addressee, \", \").concat(delivery.team, \")\"), document.querySelector(\"#storage_select\").value, checkinItem);\n          document.getElementById(\"beep\").play();\n          console.log(\"Added item by tag\");\n          return _context.abrupt(\"return\", true);\n        case 17:\n          if (response.status == 404) {\n            console.log(\"Item not found\");\n          } else {\n            (0,_util__WEBPACK_IMPORTED_MODULE_0__.checkResponseForError)(response, \"Failed to get item from backend\");\n          }\n        case 18:\n          return _context.abrupt(\"return\", false);\n        case 19:\n        case \"end\":\n          return _context.stop();\n      }\n    }, _callee);\n  }));\n  return _addItemByTag.apply(this, arguments);\n}\nfunction addItemByScan(_x2) {\n  return _addItemByScan.apply(this, arguments);\n}\n\n/*\n * Add Item without code with a image\n */\nfunction _addItemByScan() {\n  _addItemByScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(delivery_uuid) {\n    var config, response, delivery;\n    return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n      while (1) switch (_context2.prev = _context2.next) {\n        case 0:\n          (0,_scanner__WEBPACK_IMPORTED_MODULE_2__.debounceScanner)();\n          if (!(delivery_uuid.length == 36)) {\n            _context2.next = 21;\n            break;\n          }\n          console.log(\"Trying to add item by uuid (scanned)\");\n          _context2.next = 5;\n          return (0,_util__WEBPACK_IMPORTED_MODULE_0__.getConfig)();\n        case 5:\n          config = _context2.sent;\n          _context2.next = 8;\n          return (0,_auth__WEBPACK_IMPORTED_MODULE_1__.fetchWithAuth)(config.backend_url + \"/delivery/\" + delivery_uuid);\n        case 8:\n          response = _context2.sent;\n          if (!(response.status == 200)) {\n            _context2.next = 18;\n            break;\n          }\n          _context2.next = 12;\n          return response.json();\n        case 12:\n          delivery = _context2.sent;\n          (0,_util__WEBPACK_IMPORTED_MODULE_0__.addToItemList)(delivery.uuid, \"\".concat(delivery.tag, \" (\").concat(delivery.addressee, \", \").concat(delivery.team, \")\"), document.querySelector(\"#storage_select\").value, checkinItem);\n          document.getElementById(\"beep\").play();\n          console.log(\"added item by uuid (scanned)\");\n          _context2.next = 19;\n          break;\n        case 18:\n          if (response.status == 404) {\n            console.log(\"Item not found\");\n          } else {\n            (0,_util__WEBPACK_IMPORTED_MODULE_0__.checkResponseForError)(response, \"Failed to get item from backend\");\n          }\n        case 19:\n          _context2.next = 22;\n          break;\n        case 21:\n          alert(\"QR Code is not a bgp checkin code.\");\n        case 22:\n        case \"end\":\n          return _context2.stop();\n      }\n    }, _callee2);\n  }));\n  return _addItemByScan.apply(this, arguments);\n}\nfunction addItemImage(_x3) {\n  return _addItemImage.apply(this, arguments);\n}\n\n/*\n * Checkin a item from the list\n */\nfunction _addItemImage() {\n  _addItemImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(e) {\n    var form, config, response, delivery;\n    return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n      while (1) switch (_context3.prev = _context3.next) {\n        case 0:\n          console.log(\"Adding item  by image\");\n          form = new FormData();\n          form.append(\"image\", e.files[0]);\n          _context3.next = 5;\n          return (0,_util__WEBPACK_IMPORTED_MODULE_0__.getConfig)();\n        case 5:\n          config = _context3.sent;\n          _context3.next = 8;\n          return (0,_auth__WEBPACK_IMPORTED_MODULE_1__.fetchWithAuth)(config.backend_url + \"/item/register\", {\n            method: \"POST\",\n            body: form\n          });\n        case 8:\n          response = _context3.sent;\n          _context3.next = 11;\n          return (0,_util__WEBPACK_IMPORTED_MODULE_0__.checkResponseForError)(response, \"Failed to save item\");\n        case 11:\n          if (!_context3.sent) {\n            _context3.next = 18;\n            break;\n          }\n          _context3.next = 14;\n          return response.json();\n        case 14:\n          delivery = _context3.sent;\n          (0,_util__WEBPACK_IMPORTED_MODULE_0__.addToItemList)(delivery.uuid, \"\".concat(delivery.tag, \" (\").concat(delivery.addressee, \", \").concat(delivery.team, \")\"), document.querySelector(\"#storage_select\").value, checkinItem);\n          document.getElementById(\"beep\").play();\n          console.log(\"Added item by image.\");\n        case 18:\n        case \"end\":\n          return _context3.stop();\n      }\n    }, _callee3);\n  }));\n  return _addItemImage.apply(this, arguments);\n}\nfunction checkinItem() {\n  return _checkinItem.apply(this, arguments);\n}\nfunction _checkinItem() {\n  _checkinItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n    var element, storage, config, response;\n    return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n      while (1) switch (_context4.prev = _context4.next) {\n        case 0:\n          element = event.target.closest(\"div\");\n          storage = element.querySelector(\".storage\").textContent;\n          console.log(\"check in item for delivery\", element.dataset.uuid, \"at\", storage);\n          _context4.next = 5;\n          return (0,_util__WEBPACK_IMPORTED_MODULE_0__.getConfig)();\n        case 5:\n          config = _context4.sent;\n          _context4.next = 8;\n          return (0,_auth__WEBPACK_IMPORTED_MODULE_1__.fetchWithAuth)(config.backend_url + \"/item\", {\n            method: \"POST\",\n            headers: {\n              \"Content-Type\": \"application/json\"\n            },\n            body: JSON.stringify({\n              \"delivery_uuid\": element.dataset.uuid,\n              \"storage_name\": storage\n            })\n          });\n        case 8:\n          response = _context4.sent;\n          _context4.next = 11;\n          return (0,_util__WEBPACK_IMPORTED_MODULE_0__.checkResponseForError)(response, \"Failed to checkin item \" + element.dataset.uuid);\n        case 11:\n          if (!_context4.sent) {\n            _context4.next = 20;\n            break;\n          }\n          element.classList.remove(\"alert-warning\");\n          element.classList.remove(\"alert-danger\");\n          element.classList.add(\"alert-success\");\n          _context4.next = 17;\n          return new Promise(function (r) {\n            return setTimeout(r, 2000);\n          });\n        case 17:\n          element.parentNode.remove();\n          _context4.next = 22;\n          break;\n        case 20:\n          element.classList.remove(\"alert-warning\");\n          element.classList.add(\"alert-danger\");\n        case 22:\n        case \"end\":\n          return _context4.stop();\n      }\n    }, _callee4);\n  }));\n  return _checkinItem.apply(this, arguments);\n}//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9zcmMvanMvY2hlY2tpbi5qcy5qcyIsIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0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vKiNfX1BVUkVfXyovX3JlZ2VuZXJhdG9yUnVudGltZSgpLm1hcmsoZnVuY3Rpb24gX2NhbGxlZTMoZSkge1xuICAgIHZhciBmb3JtLCBjb25maWcsIHJlc3BvbnNlLCBkZWxpdmVyeTtcbiAgICByZXR1cm4gX3JlZ2VuZXJhdG9yUnVudGltZSgpLndyYXAoZnVuY3Rpb24gX2NhbGxlZTMkKF9jb250ZXh0Mykge1xuICAgICAgd2hpbGUgKDEpIHN3aXRjaCAoX2NvbnRleHQzLnByZXYgPSBfY29udGV4dDMubmV4dCkge1xuICAgICAgICBjYXNlIDA6XG4gICAgICAgICAgY29uc29sZS5sb2coXCJBZGRpbmcgaXRlbSAgYnkgaW1hZ2VcIik7XG4gICAgICAgICAgZm9ybSA9IG5ldyBGb3JtRGF0YSgpO1xuICAgICAgICAgIGZvcm0uYXBwZW5kKFwiaW1hZ2VcIiwgZS5maWxlc1swXSk7XG4gICAgICAgICAgX2NvbnRleHQzLm5leHQgPSA1O1xuICAgICAgICAgIHJldHVybiBnZXRDb25maWcoKTtcbiAgICAgICAgY2FzZSA1OlxuICAgICAgICAgIGNvbmZpZyA9IF9jb250ZXh0My5zZW50O1xuICAgICAgICAgIF9jb250ZXh0My5uZXh0ID0gODtcbiAgICAgICAgICByZXR1cm4gZmV0Y2hXaXRoQXV0aChjb25maWcuYmFja2VuZF91cmwgKyBcIi9pdGVtL3JlZ2lzdGVyXCIsIHtcbiAgICAgICAgICAgIG1ldGhvZDogXCJQT1NUXCIsXG4gICAgICAgICAgICBib2R5OiBmb3JtXG4gICAgICAgICAgfSk7XG4gICAgICAgIGNhc2UgODpcbiAgICAgICAgICByZXNwb25zZSA9IF9jb250ZXh0My5zZW50O1xuICAgICAgICAgIF9jb250ZXh0My5uZXh0ID0gMTE7XG4gICAgICAgICAgcmV0dXJuIGNoZWNrUmVzcG9uc2VGb3JFcnJvcihyZXNwb25zZSwgXCJGYWlsZWQgdG8gc2F2ZSBpdGVtXCIpO1xuICAgICA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SxcbiAgICAgICAgICAgIGJvZHk6IEpTT04uc3RyaW5naWZ5KHtcbiAgICAgICAgICAgICAgXCJkZWxpdmVyeV91dWlkXCI6IGVsZW1lbnQuZGF0YXNldC51dWlkLFxuICAgICAgICAgICAgICBcInN0b3JhZ2VfbmFtZVwiOiBzdG9yYWdlXG4gICAgICAgICAgICB9KVxuICAgICAgICAgIH0pO1xuICAgICAgICBjYXNlIDg6XG4gICAgICAgICAgcmVzcG9uc2UgPSBfY29udGV4dDQuc2VudDtcbiAgICAgICAgICBfY29udGV4dDQubmV4dCA9IDExO1xuICAgICAgICAgIHJldHVybiBjaGVja1Jlc3BvbnNlRm9yRXJyb3IocmVzcG9uc2UsIFwiRmFpbGVkIHRvIGNoZWNraW4gaXRlbSBcIiArIGVsZW1lbnQuZGF0YXNldC51dWlkKTtcbiAgICAgICAgY2FzZSAxMTpcbiAgICAgICAgICBpZiAoIV9jb250ZXh0NC5zZW50KSB7XG4gICAgICAgICAgICBfY29udGV4dDQubmV4dCA9IDIwO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgfVxuICAgICAgICAgIGVsZW1lbnQuY2xhc3NMaXN0LnJlbW92ZShcImFsZXJ0LXdhcm5pbmdcIik7XG4gICAgICAgICAgZWxlbWVudC5jbGFzc0xpc3QucmVtb3ZlKFwiYWxlcnQtZGFuZ2VyXCIpO1xuICAgICAgICAgIGVsZW1lbnQuY2xhc3NMaXN0LmFkZChcImFsZXJ0LXN1Y2Nlc3NcIik7XG4gICAgICAgICAgX2NvbnRleHQ0Lm5leHQgPSAxNztcbiAgICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoZnVuY3Rpb24gKHIpIHtcbiAgICAgICAgICAgIHJldHVybiBzZXRUaW1lb3V0KHIsIDIwMDApO1xuICAgICAgICAgIH0pO1xuICAgICAgICBjYXNlIDE3OlxuICAgICAgICAgIGVsZW1lbnQucGFyZW50Tm9kZS5yZW1vdmUoKTtcbiAgICAgICAgICBfY29udGV4dDQubmV4dCA9IDIyO1xuICAgICAgICAgIGJyZWFrO1xuICAgICAgICBjYXNlIDIwOlxuICAgICAgICAgIGVsZW1lbnQuY2xhc3NMaXN0LnJlbW92ZShcImFsZXJ0LXdhcm5pbmdcIik7XG4gICAgICAgICAgZWxlbWVudC5jbGFzc0xpc3QuYWRkKFwiYWxlcnQtZGFuZ2VyXCIpO1xuICAgICAgICBjYXNlIDIyOlxuICAgICAgICBjYXNlIFwiZW5kXCI6XG4gICAgICAgICAgcmV0dXJuIF9jb250ZXh0NC5zdG9wKCk7XG4gICAgICB9XG4gICAgfSwgX2NhbGxlZTQpO1xuICB9KSk7XG4gIHJldHVybiBfY2hlY2tpbkl0ZW0uYXBwbHkodGhpcywgYXJndW1lbnRzKTtcbn0iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./src/js/checkin.js\n");
+eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   addItemByScan: () => (/* binding */ addItemByScan),\n/* harmony export */   addItemByTag: () => (/* binding */ addItemByTag),\n/* harmony export */   addItemImage: () => (/* binding */ addItemImage),\n/* harmony export */   checkinItem: () => (/* binding */ checkinItem)\n/* harmony export */ });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ \"./src/js/util.js\");\n/* harmony import */ var _auth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./auth */ \"./src/js/auth.js\");\n/* harmony import */ var _scanner__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./scanner */ \"./src/js/scanner.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = \"function\" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || \"@@iterator\", asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\", toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, \"\"); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, \"_invoke\", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: \"normal\", arg: fn.call(obj, arg) }; } catch (err) { return { type: \"throw\", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { [\"next\", \"throw\", \"return\"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if (\"throw\" !== record.type) { var result = record.arg, value = result.value; return value && \"object\" == _typeof(value) && hasOwn.call(value, \"__await\") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke(\"next\", value, resolve, reject); }, function (err) { invoke(\"throw\", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke(\"throw\", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, \"_invoke\", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = \"suspendedStart\"; return function (method, arg) { if (\"executing\" === state) throw new Error(\"Generator is already running\"); if (\"completed\" === state) { if (\"throw\" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if (\"next\" === context.method) context.sent = context._sent = context.arg;else if (\"throw\" === context.method) { if (\"suspendedStart\" === state) throw state = \"completed\", context.arg; context.dispatchException(context.arg); } else \"return\" === context.method && context.abrupt(\"return\", context.arg); state = \"executing\"; var record = tryCatch(innerFn, self, context); if (\"normal\" === record.type) { if (state = context.done ? \"completed\" : \"suspendedYield\", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } \"throw\" === record.type && (state = \"completed\", context.method = \"throw\", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, \"throw\" === methodName && delegate.iterator[\"return\"] && (context.method = \"return\", context.arg = undefined, maybeInvokeDelegate(delegate, context), \"throw\" === context.method) || \"return\" !== methodName && (context.method = \"throw\", context.arg = new TypeError(\"The iterator does not provide a '\" + methodName + \"' method\")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if (\"throw\" === record.type) return context.method = \"throw\", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, \"return\" !== context.method && (context.method = \"next\", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = \"throw\", context.arg = new TypeError(\"iterator result is not an object\"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = \"normal\", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: \"root\" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if (\"function\" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, \"GeneratorFunction\"), exports.isGeneratorFunction = function (genFun) { var ctor = \"function\" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || \"GeneratorFunction\" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, \"GeneratorFunction\")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, \"Generator\"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, \"toString\", function () { return \"[object Generator]\"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) \"t\" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if (\"throw\" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = \"throw\", record.arg = exception, context.next = loc, caught && (context.method = \"next\", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if (\"root\" === entry.tryLoc) return handle(\"end\"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, \"catchLoc\"), hasFinally = hasOwn.call(entry, \"finallyLoc\"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error(\"try statement without catch or finally\"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, \"finallyLoc\") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && (\"break\" === type || \"continue\" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = \"next\", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if (\"throw\" === record.type) throw record.arg; return \"break\" === record.type || \"continue\" === record.type ? this.next = record.arg : \"return\" === record.type ? (this.rval = this.arg = record.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, \"catch\": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if (\"throw\" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, \"next\" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\n\n\n\n/*\n * Add items by delivery tag\n */\nfunction addItemByTag(_x) {\n  return _addItemByTag.apply(this, arguments);\n}\n\n/*\n * add items scanned from qrcode\n */\nfunction _addItemByTag() {\n  _addItemByTag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(tag) {\n    var config, response, delivery;\n    return _regeneratorRuntime().wrap(function _callee$(_context) {\n      while (1) switch (_context.prev = _context.next) {\n        case 0:\n          console.log(\"Trying to add item by tag:\", tag);\n          _context.next = 3;\n          return (0,_util__WEBPACK_IMPORTED_MODULE_0__.getConfig)();\n        case 3:\n          config = _context.sent;\n          _context.next = 6;\n          return (0,_auth__WEBPACK_IMPORTED_MODULE_1__.fetchWithAuth)(config.backend_url + \"/tag/\" + tag);\n        case 6:\n          response = _context.sent;\n          if (!(response.status == 200)) {\n            _context.next = 17;\n            break;\n          }\n          _context.next = 10;\n          return response.json();\n        case 10:\n          delivery = _context.sent;\n          (0,_util__WEBPACK_IMPORTED_MODULE_0__.addToItemList)(delivery.uuid, \"\".concat(delivery.tag, \" (\").concat(delivery.addressee, \", \").concat(delivery.team, \")\"), document.querySelector(\"#storage_select\").value, checkinItem);\n          document.getElementById(\"beep\").play();\n          console.log(\"Added item by tag\");\n          return _context.abrupt(\"return\", true);\n        case 17:\n          if (response.status == 404) {\n            console.log(\"Item not found\");\n          } else {\n            (0,_util__WEBPACK_IMPORTED_MODULE_0__.checkResponseForError)(response, \"Failed to get item from backend\");\n          }\n        case 18:\n          return _context.abrupt(\"return\", false);\n        case 19:\n        case \"end\":\n          return _context.stop();\n      }\n    }, _callee);\n  }));\n  return _addItemByTag.apply(this, arguments);\n}\nfunction addItemByScan(_x2) {\n  return _addItemByScan.apply(this, arguments);\n}\n\n/*\n * Add Item without code with a image\n */\nfunction _addItemByScan() {\n  _addItemByScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(delivery_uuid) {\n    var config, response, delivery;\n    return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n      while (1) switch (_context2.prev = _context2.next) {\n        case 0:\n          (0,_scanner__WEBPACK_IMPORTED_MODULE_2__.debounceScanner)();\n          if (!(delivery_uuid.length == 36)) {\n            _context2.next = 21;\n            break;\n          }\n          console.log(\"Trying to add item by uuid (scanned)\");\n          _context2.next = 5;\n          return (0,_util__WEBPACK_IMPORTED_MODULE_0__.getConfig)();\n        case 5:\n          config = _context2.sent;\n          _context2.next = 8;\n          return (0,_auth__WEBPACK_IMPORTED_MODULE_1__.fetchWithAuth)(config.backend_url + \"/delivery/\" + delivery_uuid);\n        case 8:\n          response = _context2.sent;\n          if (!(response.status == 200)) {\n            _context2.next = 18;\n            break;\n          }\n          _context2.next = 12;\n          return response.json();\n        case 12:\n          delivery = _context2.sent;\n          (0,_util__WEBPACK_IMPORTED_MODULE_0__.addToItemList)(delivery.uuid, \"\".concat(delivery.tag, \" (\").concat(delivery.addressee, \", \").concat(delivery.team, \")\"), document.querySelector(\"#storage_select\").value, checkinItem);\n          document.getElementById(\"beep\").play();\n          console.log(\"added item by uuid (scanned)\");\n          _context2.next = 19;\n          break;\n        case 18:\n          if (response.status == 404) {\n            console.log(\"Item not found\");\n          } else {\n            (0,_util__WEBPACK_IMPORTED_MODULE_0__.checkResponseForError)(response, \"Failed to get item from backend\");\n          }\n        case 19:\n          _context2.next = 22;\n          break;\n        case 21:\n          alert(\"QR Code is not a bgp checkin code.\");\n        case 22:\n        case \"end\":\n          return _context2.stop();\n      }\n    }, _callee2);\n  }));\n  return _addItemByScan.apply(this, arguments);\n}\nfunction addItemImage(_x3) {\n  return _addItemImage.apply(this, arguments);\n}\n\n/*\n * Checkin a item from the list\n */\nfunction _addItemImage() {\n  _addItemImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(e) {\n    var form, config, response, delivery;\n    return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n      while (1) switch (_context3.prev = _context3.next) {\n        case 0:\n          console.log(\"Adding item  by image\");\n          form = new FormData();\n          form.append(\"image\", e.files[0]);\n          _context3.next = 5;\n          return (0,_util__WEBPACK_IMPORTED_MODULE_0__.getConfig)();\n        case 5:\n          config = _context3.sent;\n          _context3.next = 8;\n          return (0,_auth__WEBPACK_IMPORTED_MODULE_1__.fetchWithAuth)(config.backend_url + \"/item/register?storage_name=\" + document.querySelector(\"#storage_select\").value, {\n            method: \"POST\",\n            body: form\n          });\n        case 8:\n          response = _context3.sent;\n          _context3.next = 11;\n          return (0,_util__WEBPACK_IMPORTED_MODULE_0__.checkResponseForError)(response, \"Failed to save item\");\n        case 11:\n          if (!_context3.sent) {\n            _context3.next = 17;\n            break;\n          }\n          _context3.next = 14;\n          return response.json();\n        case 14:\n          delivery = _context3.sent;\n          document.getElementById(\"beep\").play();\n          console.log(\"Added item by image.\");\n        case 17:\n        case \"end\":\n          return _context3.stop();\n      }\n    }, _callee3);\n  }));\n  return _addItemImage.apply(this, arguments);\n}\nfunction checkinItem() {\n  return _checkinItem.apply(this, arguments);\n}\nfunction _checkinItem() {\n  _checkinItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n    var element, storage, config, response;\n    return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n      while (1) switch (_context4.prev = _context4.next) {\n        case 0:\n          element = event.target.closest(\"div\");\n          storage = element.querySelector(\".storage\").textContent;\n          console.log(\"check in item for delivery\", element.dataset.uuid, \"at\", storage);\n          _context4.next = 5;\n          return (0,_util__WEBPACK_IMPORTED_MODULE_0__.getConfig)();\n        case 5:\n          config = _context4.sent;\n          _context4.next = 8;\n          return (0,_auth__WEBPACK_IMPORTED_MODULE_1__.fetchWithAuth)(config.backend_url + \"/item\", {\n            method: \"POST\",\n            headers: {\n              \"Content-Type\": \"application/json\"\n            },\n            body: JSON.stringify({\n              \"delivery_uuid\": element.dataset.uuid,\n              \"storage_name\": storage\n            })\n          });\n        case 8:\n          response = _context4.sent;\n          _context4.next = 11;\n          return (0,_util__WEBPACK_IMPORTED_MODULE_0__.checkResponseForError)(response, \"Failed to checkin item \" + element.dataset.uuid);\n        case 11:\n          if (!_context4.sent) {\n            _context4.next = 20;\n            break;\n          }\n          element.classList.remove(\"alert-warning\");\n          element.classList.remove(\"alert-danger\");\n          element.classList.add(\"alert-success\");\n          _context4.next = 17;\n          return new Promise(function (r) {\n            return setTimeout(r, 2000);\n          });\n        case 17:\n          element.parentNode.remove();\n          _context4.next = 22;\n          break;\n        case 20:\n          element.classList.remove(\"alert-warning\");\n          element.classList.add(\"alert-danger\");\n        case 22:\n        case \"end\":\n          return _context4.stop();\n      }\n    }, _callee4);\n  }));\n  return _checkinItem.apply(this, arguments);\n}//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9zcmMvanMvY2hlY2tpbi5qcy5qcyIsIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO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ZXQudXVpZCxcbiAgICAgICAgICAgICAgXCJzdG9yYWdlX25hbWVcIjogc3RvcmFnZVxuICAgICAgICAgICAgfSlcbiAgICAgICAgICB9KTtcbiAgICAgICAgY2FzZSA4OlxuICAgICAgICAgIHJlc3BvbnNlID0gX2NvbnRleHQ0LnNlbnQ7XG4gICAgICAgICAgX2NvbnRleHQ0Lm5leHQgPSAxMTtcbiAgICAgICAgICByZXR1cm4gY2hlY2tSZXNwb25zZUZvckVycm9yKHJlc3BvbnNlLCBcIkZhaWxlZCB0byBjaGVja2luIGl0ZW0gXCIgKyBlbGVtZW50LmRhdGFzZXQudXVpZCk7XG4gICAgICAgIGNhc2UgMTE6XG4gICAgICAgICAgaWYgKCFfY29udGV4dDQuc2VudCkge1xuICAgICAgICAgICAgX2NvbnRleHQ0Lm5leHQgPSAyMDtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAgICAgICAgICBlbGVtZW50LmNsYXNzTGlzdC5yZW1vdmUoXCJhbGVydC13YXJuaW5nXCIpO1xuICAgICAgICAgIGVsZW1lbnQuY2xhc3NMaXN0LnJlbW92ZShcImFsZXJ0LWRhbmdlclwiKTtcbiAgICAgICAgICBlbGVtZW50LmNsYXNzTGlzdC5hZGQoXCJhbGVydC1zdWNjZXNzXCIpO1xuICAgICAgICAgIF9jb250ZXh0NC5uZXh0ID0gMTc7XG4gICAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyKSB7XG4gICAgICAgICAgICByZXR1cm4gc2V0VGltZW91dChyLCAyMDAwKTtcbiAgICAgICAgICB9KTtcbiAgICAgICAgY2FzZSAxNzpcbiAgICAgICAgICBlbGVtZW50LnBhcmVudE5vZGUucmVtb3ZlKCk7XG4gICAgICAgICAgX2NvbnRleHQ0Lm5leHQgPSAyMjtcbiAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSAyMDpcbiAgICAgICAgICBlbGVtZW50LmNsYXNzTGlzdC5yZW1vdmUoXCJhbGVydC13YXJuaW5nXCIpO1xuICAgICAgICAgIGVsZW1lbnQuY2xhc3NMaXN0LmFkZChcImFsZXJ0LWRhbmdlclwiKTtcbiAgICAgICAgY2FzZSAyMjpcbiAgICAgICAgY2FzZSBcImVuZFwiOlxuICAgICAgICAgIHJldHVybiBfY29udGV4dDQuc3RvcCgpO1xuICAgICAgfVxuICAgIH0sIF9jYWxsZWU0KTtcbiAgfSkpO1xuICByZXR1cm4gX2NoZWNraW5JdGVtLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7XG59Il0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///./src/js/checkin.js\n");
 
 /***/ }),
 
diff --git a/src/js/checkin.js b/src/js/checkin.js
index 3cc8225..f773f29 100644
--- a/src/js/checkin.js
+++ b/src/js/checkin.js
@@ -76,18 +76,12 @@ export async function addItemImage(e) {
   var form = new FormData();
   form.append("image", e.files[0]);
   var config = await getConfig();
-  var response = await fetchWithAuth(config.backend_url + "/item/register", {
+  var response = await fetchWithAuth(config.backend_url + "/item/register?storage_name="+document.querySelector("#storage_select").value, {
     method: "POST",
     body: form
   });
   if(await checkResponseForError(response, "Failed to save item")) {
     var delivery = await response.json();
-    addToItemList(
-      delivery.uuid, 
-      `${ delivery.tag } (${ delivery.addressee }, ${ delivery.team })`, 
-      document.querySelector("#storage_select").value, 
-      checkinItem
-    );
     document.getElementById("beep").play();
     console.log("Added item by image.");
   }
-- 
GitLab