From 6aef803ba46ee7a2c414398560d001ae2e259a0d Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 1 Feb 2022 19:52:22 -0700 Subject: [PATCH] Add receipt viewer to account page --- www/assets/css/app.css | 8 ++++++ www/assets/js/account.js | 22 +++++++++++++++ www/pages/account.html | 13 +++++++-- www/pages/receipts.html | 60 ++++++++++++++++++++++++++++++++++++++++ www/routes.js | 32 ++++++++++++++++++++- www/settings.js | 4 ++- 6 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 www/pages/receipts.html diff --git a/www/assets/css/app.css b/www/assets/css/app.css index 6632927..a14be37 100644 --- a/www/assets/css/app.css +++ b/www/assets/css/app.css @@ -271,6 +271,14 @@ Framework7 and FontAwesome both have a .fab class height: 30vh; } +#receiptvieweriframe { + width: 100%; + height: calc(100% - var(--f7-navbar-height)); + border: 0; + padding: 0; + margin: 0; +} + @media all and (min-width: 1024px) { #trackMapContainer { height: calc(calc(100vh - calc(var(--f7-list-margin-vertical) * 2)) - var(--f7-navbar-height)); diff --git a/www/assets/js/account.js b/www/assets/js/account.js index 8835c85..7fef679 100644 --- a/www/assets/js/account.js +++ b/www/assets/js/account.js @@ -306,4 +306,26 @@ function openCheckoutWindowToSaveCard(onaccountpage) { setTimeout(initAccountPage, 1000 * 60); setTimeout(initAccountPage, 1000 * 90); setTimeout(initAccountPage, 1000 * 120); +} + +function loadReceiptHTMLIntoPopup(receiptid) { + app.dialog.preloader("Loading..."); + apirequest(SETTINGS.apis.getreceipt, { + accountnumber: getStorage("accountnumber"), + accountkey: getStorage("accountkey"), + receiptid: receiptid + }, function (success) { + app.dialog.close(); + if (success.status == "OK") { + $('#receiptvieweriframe').attr("src", "data:text/html," + encodeURIComponent(success.receipt.html)); + app.popup.open("#receiptViewerPopup"); + } else { + app.dialog.alert(success.msg, "Error"); + sendErrorReport("Receipts", "Loading receipt", success.msg); + } + }, function (xhr, status, error) { + app.dialog.close(); + app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error"); + sendErrorReport("Receipts", "Couldn't load receipt", "Server/network problem: " + xhr.status + ": " + xhr.statusText); + }, "POST"); } \ No newline at end of file diff --git a/www/pages/account.html b/www/pages/account.html index b9bdc9c..eafa04c 100644 --- a/www/pages/account.html +++ b/www/pages/account.html @@ -45,8 +45,17 @@

...

-
- +
+
+ +
+
+
+ +
+
diff --git a/www/pages/receipts.html b/www/pages/receipts.html new file mode 100644 index 0000000..615fe47 --- /dev/null +++ b/www/pages/receipts.html @@ -0,0 +1,60 @@ + + +
+ + + + +
+
+
+
+
    + {{#each receipts}} +
  • + +
  • + {{/each}} +
+
+
+
+
+ + + +
\ No newline at end of file diff --git a/www/routes.js b/www/routes.js index 2b2e2a0..86a10da 100644 --- a/www/routes.js +++ b/www/routes.js @@ -17,7 +17,8 @@ var pagesToCompile = [ "rateresult", "account", "trackresult", - "settings" + "settings", + "receipts" ]; console.log("Compiling page templates..."); for (var i = 0; i < pagesToCompile.length; i++) { @@ -298,6 +299,35 @@ var routes = [ } } }, + { + path: '/receipts', + name: 'receipts', + async: function ( {resolve, reject}) { + app.dialog.preloader("Loading..."); + apirequest(SETTINGS.apis.getreceipts, { + accountnumber: getStorage("accountnumber"), + accountkey: getStorage("accountkey") + }, function (success) { + app.dialog.close(); + if (success.status == "OK") { + resolve({ + content: compiledPages.receipts({ + receipts: success.receipts + }) + }); + } else { + app.dialog.alert(success.msg, "Error"); + sendErrorReport("Receipts", "Loading receipt list", success.msg); + reject(); + } + }, function (xhr, status, error) { + app.dialog.close(); + app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error"); + sendErrorReport("Receipts", "Couldn't load receipts", "Server/network problem: " + xhr.status + ": " + xhr.statusText); + reject(); + }, "POST"); + } + }, { path: '/credits', url: './pages/credits.html', diff --git a/www/settings.js b/www/settings.js index c8d381e..255ad2c 100644 --- a/www/settings.js +++ b/www/settings.js @@ -21,7 +21,9 @@ var SETTINGS = { finishpaymentsetup: "http://localhost/helena.express/apis/account/finishpaymentsetup/", sendtelegram: "http://localhost/helena.express/apis/telegram", shopitems: "http://localhost/helena.express/apis/shop/items", - shopbuy: "http://localhost/helena.express/apis/shop/buy" + shopbuy: "http://localhost/helena.express/apis/shop/buy", + getreceipts: "http://localhost/helena.express/apis/account/getreceipts", + getreceipt: "http://localhost/helena.express/apis/account/getreceipt" }, stripe_pubkey: "pk_test_51J6qFXCa1Fboir5UzPO3LCiMsVNiFP2lq4wR0dEcjJJVzAaJ3uRggDekZPB3qeYpMD3ayIYHKyD5sSn0IFLlEXMW001LqrvGSH", branding: {