From ee3b161b47775245abb24aeb91819fc5e0ff587a Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Wed, 19 Jul 2023 11:50:47 +0300 Subject: [PATCH] feat: add readNotes and clearAllData option --- .../market-config/market-config.html | 91 ++++++++++++++++--- .../components/market-config/market-config.js | 21 +++-- .../components/user-config/user-config.html | 10 +- static/components/user-config/user-config.js | 3 +- static/js/market.js | 42 +++++++-- templates/nostrmarket/market.html | 39 ++++++-- 6 files changed, 166 insertions(+), 40 deletions(-) diff --git a/static/components/market-config/market-config.html b/static/components/market-config/market-config.html index 4bb9a37..59b6082 100644 --- a/static/components/market-config/market-config.html +++ b/static/components/market-config/market-config.html @@ -18,6 +18,43 @@ + + + + + + + + + Note + +
+
    +
  • + Here all the mercants of the marketplace are listed. + +
  • +
  • + + You can easily add a new merchant by + entering its public key in the input below. + +
  • +
  • + + When a merchant is added all its products and stalls will be available in the Market page. + +
  • +
+
+
+
+ + + +
+
@@ -66,12 +103,6 @@ {{ relay}} - - @@ -83,24 +114,59 @@
+ + + + + + + + + Note + +
+
    +
  • + Here one can customize the look and feel of the Market. + +
  • +
  • + + When the Market Profile is shared (via naddr ) these customisations will be + available to the + customers. + +
  • +
+
+
+
+ + + +
+
Information
- + + label="Marketplace Description" + hint="It will be displayed on top of the banner image. Can be a longer text." class="q-mb-lg">
UI Configurations
+ hint="It will be displayed next to the search input. Can be png, jpg, ico, gif, svg." class="q-mb-md"> + hint="It represents the visual identity of the market. Can be png, jpg, ico, gif, svg." class="q-mb-md"> -
+
diff --git a/static/components/market-config/market-config.js b/static/components/market-config/market-config.js index 0bcf3f6..f271571 100644 --- a/static/components/market-config/market-config.js +++ b/static/components/market-config/market-config.js @@ -2,7 +2,7 @@ async function marketConfig(path) { const template = await loadTemplateAsync(path) Vue.component('market-config', { name: 'market-config', - props: ['merchants', 'relays', 'config-ui'], + props: ['merchants', 'relays', 'config-ui', 'read-notes'], template, data: function () { @@ -85,17 +85,26 @@ async function marketConfig(path) { console.log('### this.info', { name, about, ui }) this.$emit('ui-config-update', { name, about, ui }) }, - publishNaddr(){ + publishNaddr() { this.$emit('publish-naddr') + }, + clearAllData() { + this.$emit('clear-all-data') + }, + markNoteAsRead(noteId) { + this.$emit('note-read', noteId) } }, created: async function () { - console.log('### this.configData', this.configData) - console.log('### this.configUi', this.configUi) if (this.configUi) { - this.configData = { ...this.configData, ...this.configUi, ui: { ...this.configData.ui, ...(this.configUi.ui || {}) } } + this.configData = { + ...this.configData, + ...this.configUi, + ui: { + ...this.configData.ui, ...(this.configUi.ui || {}) + } + } } - console.log('### this.configData', this.configData) } }) diff --git a/static/components/user-config/user-config.html b/static/components/user-config/user-config.html index ecd5975..54cc5f1 100644 --- a/static/components/user-config/user-config.html +++ b/static/components/user-config/user-config.html @@ -19,23 +19,23 @@
- +
- +
-
diff --git a/static/components/user-config/user-config.js b/static/components/user-config/user-config.js index 85695d2..9ca33f8 100644 --- a/static/components/user-config/user-config.js +++ b/static/components/user-config/user-config.js @@ -7,7 +7,6 @@ async function userConfig(path) { data: function () { return { - clearAllData: false } }, methods: { @@ -17,7 +16,7 @@ async function userConfig(path) { 'Please make sure you save your private key! You will not be able to recover it later!' ) .onOk(async () => { - this.$emit('logout', { clearAllData: this.clearAllData }) + this.$emit('logout') }) }, copyText(text) { diff --git a/static/js/market.js b/static/js/market.js index 3a0a3e6..0ba38cd 100644 --- a/static/js/market.js +++ b/static/js/market.js @@ -103,7 +103,11 @@ const market = async () => { defaultBanner: '/nostrmarket/static/images/nostr-cover.png', - defaultLogo: '/nostrmarket/static/images/nostr-avatar.png' + defaultLogo: '/nostrmarket/static/images/nostr-avatar.png', + readNotes: { + merchants: false, + marketUi: false + } } }, watch: { @@ -287,6 +291,9 @@ const market = async () => { const relays = this.$q.localStorage.getItem('nostrmarket.relays') this.relays = new Set(relays?.length ? relays : defaultRelays) + + const readNotes = this.$q.localStorage.getItem('nostrmarket.readNotes') || {} + this.readNotes = { ...this.readNotes, ...readNotes } }, applyUiConfigs(config = {}) { const { name, about, ui } = config?.opts || {} @@ -926,15 +933,38 @@ const market = async () => { this.copyText(naddr) }, - logout(opts) { + logout() { window.localStorage.removeItem('nostrmarket.account') + window.location.href = window.location.origin + window.location.pathname; this.account = null - if (opts?.clearAllData) { - this.$q.localStorage.getAllKeys().forEach(key => window.localStorage.removeItem(key)) - window.location.href = window.location.origin + window.location.pathname; - } + this.accountMetadata = null + }, + clearAllData() { + LNbits.utils + .confirmDialog( + 'This will remove all information about merchants, products, relays and others. ' + + 'You will NOT be logged out. Do you want to proceed?' + ) + .onOk(async () => { + this.$q.localStorage.getAllKeys() + .filter(key => key !== 'nostrmarket.account') + .forEach(key => window.localStorage.removeItem(key)) + this.merchants = [] + this.relays = [] + this.orders = [] + this.config = { opts: null } + this.shoppingCarts = [] + this.checkoutCart = null + window.location.href = window.location.origin + window.location.pathname; + + }) + + }, + markNoteAsRead(noteId) { + this.readNotes[noteId] = true + this.$q.localStorage.set('nostrmarket.readNotes', this.readNotes) } } diff --git a/templates/nostrmarket/market.html b/templates/nostrmarket/market.html index 8b63eb1..e70254d 100644 --- a/templates/nostrmarket/market.html +++ b/templates/nostrmarket/market.html @@ -129,8 +129,9 @@ + @remove-merchant="removeMerchant" :relays="relays" :read-notes="readNotes" @add-relay="addRelay" + @remove-relay="removeRelay" :config-ui="config?.opts" @ui-config-update="updateUiConfig" + @publish-naddr="publishNaddr" @clear-all-data="clearAllData" @note-read="markNoteAsRead"> @@ -152,15 +153,35 @@ :stall="stalls.find(stall => stall.id == activeStall)" :products="filterProducts" :product-detail="activeProduct" @change-page="navigateTo" @add-to-cart="addProductToCart"> -
+
+ + + + + + - You can start by adding a merchant public key - Here -
- Or enter a nostr market profile ( naddr) in the - filter input. - +
+ + Note + + +
+ You can start by adding a merchant public key + Here +
+ Or enter a nostr market profile ( naddr) in the + filter input. + +
+
+
+ + + +
+