From 4a69f023b36ab80d4affb6f7ba7967086fe82ebe Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Mon, 20 Mar 2023 10:45:55 +0000 Subject: [PATCH] feat: show not enough stock message --- .../customer-stall/customer-stall.html | 5 ++- .../customer-stall/customer-stall.js | 39 ++++++------------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/static/components/customer-stall/customer-stall.html b/static/components/customer-stall/customer-stall.html index 1575c55..a07aef0 100644 --- a/static/components/customer-stall/customer-stall.html +++ b/static/components/customer-stall/customer-stall.html @@ -215,7 +215,10 @@ >
- +
+

{{ qrCodeDialog.data.message }}

+
+
{ this.qrCodeDialog.dismissMsg() }, 1000) @@ -277,32 +282,7 @@ async function customerStall(path) { let pub = this.pool.publish(Array.from(this.relays), order) pub.on('ok', () => console.debug(`Order event was sent`)) pub.on('failed', error => console.error(error)) - // for (const url of Array.from(this.relays)) { - // try { - // let relay = NostrTools.relayInit(url) - // relay.on('connect', () => { - // console.debug(`connected to ${relay.url}`) - // }) - // relay.on('error', () => { - // console.debug(`failed to connect to ${relay.url}`) - // relay.close() - // return - // }) - // await relay.connect() - // let pub = relay.publish(order) - // pub.on('ok', () => { - // console.debug(`${relay.url} has accepted our event: ${order.id}`) - // relay.close() - // }) - // pub.on('failed', reason => { - // console.debug(`failed to publish to ${relay.url}: ${reason}`) - // relay.close() - // }) - // } catch (err) { - // console.error(`Error: ${err}`) - // } - // } this.loading = false this.resetCart() this.openQrCodeDialog() @@ -311,7 +291,6 @@ async function customerStall(path) { async listenMessages() { this.loading = true try { - // const pool = new NostrTools.SimplePool() const filters = [ { kinds: [4], @@ -357,6 +336,12 @@ async function customerStall(path) { if (!isJson(text)) return let json = JSON.parse(text) if (json.id != this.activeOrder) return + + if (json.payment_options.length == 0 && json.message) { + this.loading = false + this.qrCodeDialog.data.message = json.message + return cb() + } if (json.payment_options) { let payment_request = json.payment_options.find(o => o.type == 'ln') .link