diff --git a/static/components/merchant-tab.js b/static/components/merchant-tab.js index cd2e2b2..1194420 100644 --- a/static/components/merchant-tab.js +++ b/static/components/merchant-tab.js @@ -19,7 +19,9 @@ window.app.component('merchant-tab', { 'merchant-deleted', 'toggle-merchant-state', 'restart-nostr-connection', - 'profile-updated' + 'profile-updated', + 'import-key', + 'generate-key' ], data: function () { return { @@ -57,6 +59,32 @@ window.app.component('merchant-tab', { handleMerchantDeleted: function () { this.$emit('merchant-deleted') }, + removeMerchant: function () { + const name = + this.merchantConfig?.display_name || + this.merchantConfig?.name || + 'this merchant' + LNbits.utils + .confirmDialog( + `Are you sure you want to remove "${name}"? This will delete all associated data (stalls, products, orders, messages).` + ) + .onOk(async () => { + try { + await LNbits.api.request( + 'DELETE', + `/nostrmarket/api/v1/merchant/${this.merchantId}`, + this.adminkey + ) + this.$emit('merchant-deleted') + this.$q.notify({ + type: 'positive', + message: 'Merchant removed' + }) + } catch (error) { + LNbits.utils.notifyApiError(error) + } + }) + }, toggleMerchantState: function () { this.$emit('toggle-merchant-state') }, diff --git a/templates/nostrmarket/components/merchant-tab.html b/templates/nostrmarket/components/merchant-tab.html index d4f8e34..5725de3 100644 --- a/templates/nostrmarket/components/merchant-tab.html +++ b/templates/nostrmarket/components/merchant-tab.html @@ -70,12 +70,38 @@ + + + + + Import Existing Key + Use an existing nsec + + + - Add New Profile - Import a different nsec + Generate New Key + Create a fresh nsec + + + + + + + + + Remove + + Remove this nPub from the DB diff --git a/templates/nostrmarket/index.html b/templates/nostrmarket/index.html index 69e7e2e..7fe4e2c 100644 --- a/templates/nostrmarket/index.html +++ b/templates/nostrmarket/index.html @@ -159,6 +159,7 @@ @toggle-merchant-state="toggleMerchantState" @restart-nostr-connection="restartNostrConnection" @import-key="showImportKeysDialog" + @generate-key="generateKeys" @profile-updated="getMerchant" >