INSERT INTO `cp_filejs` (`id`,`app`,`path`,`modul`,`file_name`,`content`) VALUES ('239','1','u2/creator','scanner','js/qr-scanner.js--','import {\r\n verifyScan\r\n} from \\\\\\\"./api/scanner.js\\\\\\\"\r\nimport store from \\\\\\\"./store.js\\\\\\\"\r\n\r\nexport const onScanSuccess = async (decodedText) => {\r\n // https://mydrivelife.com/qr/clpmhHGEXyUD\r\n // get the qr code and verify it\r\n\r\n if (store.getters.isScanningQrCode.value) {\r\n return\r\n }\r\n\r\n store.dispatch(\\\\\\\'setScanningQrCode\\\\\\\', true)\r\n\r\n try {\r\n const url = new URL(decodedText)\r\n\r\n if (url.hostname === \\\\\\\'mydrivelife.com\\\\\\\') {\r\n const qrCode = url.pathname.split(\\\\\\\'/\\\\\\\').pop()\r\n if (qrCode) {\r\n const response = await verifyScan(qrCode)\r\n store.dispatch(\\\\\\\'setScannedData\\\\\\\', response)\r\n store.dispatch(\\\\\\\'setScanningQrCode\\\\\\\', false)\r\n }\r\n } else {\r\n store.dispatch(\\\\\\\'setScannedData\\\\\\\', {\r\n status: \\\\\\\'error\\\\\\\',\r\n message: \\\\\\\'Oops, looks like you scanned an invalid QR code\\\\\\\',\r\n available: false\r\n })\r\n store.dispatch(\\\\\\\'setScanningQrCode\\\\\\\', false)\r\n }\r\n } catch (error) {\r\n console.log(\\\\\\\'error\\\\\\\', error)\r\n }\r\n}\r\n\r\nexport function onScanFailure(error) {\r\n // handle scan failure, usually better to ignore and keep scanning.\r\n // for example:\r\n // console.warn(`Code scan error = ${error}`)\r\n}');