From 971ed994e0d82afd5c01594dd1d2d5ab7b8f00e8 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Wed, 8 Sep 2021 21:17:29 -0600 Subject: [PATCH] Add and fix a lot of things with accounts and drop and send. Add geolocation plugin. Remove pick up and redeliver. --- config.xml | 11 ++++++++- package-lock.json | 6 +++++ package.json | 6 ++++- www/assets/js/account.js | 3 +++ www/assets/js/dropandsend.js | 4 ++- www/assets/js/storage.js | 4 +++ www/assets/js/stripe.js | 48 ++++++++++++++++++++++++++++++++++++ www/index.html | 2 +- www/pages/dropandsend.html | 3 +++ www/pages/home.html | 16 ++++++++++++ www/routes.js | 44 +++++++++++++++++++++------------ 11 files changed, 127 insertions(+), 20 deletions(-) create mode 100644 www/assets/js/stripe.js diff --git a/config.xml b/config.xml index 134f6b5..651d57d 100644 --- a/config.xml +++ b/config.xml @@ -79,7 +79,16 @@ - Camera is used to scan receipts and redelivery notice slips + Your camera is used to scan receipts and pickup codes. + + + Your location is used to pinpoint your location on a map. It does not leave your device. + + + Your location is used to pinpoint your location on a map. It does not leave your device. + + + Your location is used to pinpoint your location on a map. It does not leave your device. diff --git a/package-lock.json b/package-lock.json index 1274004..44db88f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -622,6 +622,12 @@ "resolved": "https://registry.npmjs.org/cordova-plugin-device/-/cordova-plugin-device-2.0.3.tgz", "integrity": "sha1-wrQbfv0EVd0Jf4k1bYW/3V2t6w8=" }, + "cordova-plugin-geolocation": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cordova-plugin-geolocation/-/cordova-plugin-geolocation-4.1.0.tgz", + "integrity": "sha512-y5io/P10xGMxSn2KEqfv/fExK47eA1pmSonJdmDqDsaSADV9JpgdPx0mUSA08+5pzma/OS9R0LoODeDPx7Jvjg==", + "dev": true + }, "cordova-plugin-headercolor": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/cordova-plugin-headercolor/-/cordova-plugin-headercolor-1.0.0.tgz", diff --git a/package.json b/package.json index c0e1fbf..ce79ff7 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,10 @@ "ANDROID_SUPPORT_V4_VERSION": "27.+" }, "cordova-plugin-x-socialsharing": {}, - "cordova-plugin-velda-devicefeedback": {} + "cordova-plugin-velda-devicefeedback": {}, + "cordova-plugin-geolocation": { + "GPS_REQUIRED": "true" + } }, "platforms": [ "browser", @@ -58,6 +61,7 @@ "cordova-plugin-androidx": "^3.0.0", "cordova-plugin-androidx-adapter": "^1.1.3", "cordova-plugin-camera": "^5.0.1", + "cordova-plugin-geolocation": "^4.1.0", "cordova-plugin-nativestorage": "^2.3.2", "cordova-plugin-splashscreen": "^6.0.0", "cordova-plugin-velda-devicefeedback": "0.0.2", diff --git a/www/assets/js/account.js b/www/assets/js/account.js index 300e599..9221190 100644 --- a/www/assets/js/account.js +++ b/www/assets/js/account.js @@ -25,6 +25,9 @@ function checkAccountStatus(callback) { } } else { router.back(); + // Server is saying something's wrong, let's clear the account number in case + // the user wants to try a different one. + removeFromStorage("phonenumber"); app.dialog.alert(resp.msg, "Error"); } }, function (err) { diff --git a/www/assets/js/dropandsend.js b/www/assets/js/dropandsend.js index 3b90baf..9957b92 100644 --- a/www/assets/js/dropandsend.js +++ b/www/assets/js/dropandsend.js @@ -10,10 +10,12 @@ function captureAndSendPickupCode() { var coderegex = /^[0-9a-zA-Z]{5,40}$/; if (result.startsWith("https://helena.express/dropandsend#")) { code = result.split("#")[1]; + } else if (result.startsWith("https://helena.express/das/pickup#")) { + code = result.split("#")[1]; } else if (coderegex.test(result)) { code = result; } else { - app.dialog.alert("That's not a valid drop box code.", "Error"); + app.dialog.alert("That's not a valid Drop and Send pickup code.", "Error"); return; } sendPickupCode(code); diff --git a/www/assets/js/storage.js b/www/assets/js/storage.js index 8fcc279..d03e5bf 100644 --- a/www/assets/js/storage.js +++ b/www/assets/js/storage.js @@ -24,6 +24,10 @@ function getStorage(key) { return localStorage.getItem(key); } +function removeFromStorage(key) { + localStorage.removeItem(key); +} + /** * Check if an item is in the persistent storage. * @param {string} key diff --git a/www/assets/js/stripe.js b/www/assets/js/stripe.js new file mode 100644 index 0000000..19302a5 --- /dev/null +++ b/www/assets/js/stripe.js @@ -0,0 +1,48 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +var stripeLoaded = false; + +function loadStripeJs(callback) { + if (stripeLoaded) { + callback(); + } else { + $.getScript("https://js.stripe.com/v3/", function () { + stripeLoaded = true; + callback(); + }); + } +} + +function initStripeJs(callback) { + // Wait for Stripe to be loaded + if (typeof Stripe == 'undefined') { + setTimeout(initStripeJs, 500); + return; + } + stripe = Stripe(SETTINGS["stripe_pubkey"]); + callback(); +} + + +function initStripeElements(elementsselector, errormsgselector) { + elements = stripe.elements(); + + card = elements.create('card'); + + // stop console warning "This Element will be mounted to a DOM element that contains child nodes." + $(elementsselector).html(""); + + card.mount(elementsselector); + + card.addEventListener('change', function (event) { + if (event.error) { + $(errormsgselector).text(event.error.message); + } else { + $(errormsgselector).text(""); + } + }); +} \ No newline at end of file diff --git a/www/index.html b/www/index.html index 4e3001f..a05e730 100644 --- a/www/index.html +++ b/www/index.html @@ -54,7 +54,7 @@ - + diff --git a/www/pages/dropandsend.html b/www/pages/dropandsend.html index a943ed8..65881bb 100644 --- a/www/pages/dropandsend.html +++ b/www/pages/dropandsend.html @@ -55,6 +55,9 @@ +
+ By using Drop and Send you agree to the terms of service. +
diff --git a/www/pages/home.html b/www/pages/home.html index 65aabe2..6303686 100644 --- a/www/pages/home.html +++ b/www/pages/home.html @@ -20,6 +20,22 @@
+ {{#if accountsetup}}{{else}} +
+
+
+

+
+ Finish Account Setup +
+ You need to set up an account to use drop boxes + and earn rewards points. It only takes a minute, + clicktap + here to get started! +
+
+
+ {{/if}}
Track Package diff --git a/www/routes.js b/www/routes.js index 3449ed4..4ed9896 100644 --- a/www/routes.js +++ b/www/routes.js @@ -8,12 +8,30 @@ var routes = [ { path: '/home', name: 'home', + on: { + pageBeforeIn: function () { + // make sure it's not shown right after account setup + var accountsetup = (inStorage("accountkey") && inStorage("phonenumber")); + if (accountsetup) { + $("#finishaccountsetupnag").css("display", "none"); + } + } + }, async: function (routeTo, routeFrom, resolve, reject) { + // Show a nag message if no account is set up + var accountsetup = (inStorage("accountkey") && inStorage("phonenumber")); resolve({ templateUrl: './pages/home.html' }, { context: { + accountsetup: accountsetup, pages: [ + { + title: "Drop and Send", + href: "/dropandsend", + icon: "fad fa-box-alt", + text: "Bring your package to a secure drop location and we'll ship it for you. No postage or appointment needed." + }, { title: "Book Appointment", href: "/appointment", @@ -21,10 +39,10 @@ var routes = [ text: "Get mailing, shipping, and notary services on your schedule anywhere in the Helena area." }, { - title: "Drop and Send", - href: "/dropandsend", - icon: "fad fa-box-alt", - text: "Bring your package to a secure drop location and we'll ship it for you. No postage or appointment needed." + title: "My Account", + href: "/account", + icon: "fad fa-user-circle", + text: "Manage your Helena Express account and check rewards points balance." }, // { // title: "Track Package", @@ -38,24 +56,18 @@ var routes = [ // icon: "fad fa-calculator", // text: "Calculate postage and prices for your item." // }, - { - title: "My Account", - href: "/account", - icon: "fad fa-user-circle", - text: "Earn rewards and use Drop and Send with a Helena Express account." - }, // { // title: "Express Pickup", // href: "/addresscode", // icon: "fal fa-qrcode", // text: "Get a faster pickup and a discount by pre-typing the destination address here." // }, - { - title: "Pick Up and Redeliver", - href: "/noticeslip", - icon: "fad fa-sticky-note", - text: "Take a picture of your pink postal notice slip and we'll go get your missed delivery." - } +// { +// title: "Pick Up and Redeliver", +// href: "/noticeslip", +// icon: "fad fa-sticky-note", +// text: "Take a picture of your pink postal notice slip and we'll go get your missed delivery." +// } ] } });