nostrmarket/static/components/market-config/market-config.js
2023-07-18 16:40:43 +02:00

37 lines
1.2 KiB
JavaScript

async function marketConfig(path) {
const template = await loadTemplateAsync(path)
Vue.component('market-config', {
name: 'market-config',
props: ['merchants',],
template,
data: function () {
return {
tab: 'merchants',
pubkeys: new Set(),
profiles: new Map(),
inputPubkey: null,
}
},
methods: {
addMerchant: async function () {
if (!isValidKey(this.inputPubkey, 'npub')) {
this.$q.notify({
message: 'Invalid Public Key!',
type: 'warning'
})
return
}
const publicKey = isValidKeyHex(this.inputPubkey) ? this.inputPubkey : NostrTools.nip19.decode(this.inputPubkey).data
this.$emit('add-merchant', publicKey)
this.inputPubkey = null
},
removeMerchant: async function (publicKey) {
this.$emit('remove-merchant', publicKey)
},
},
created: async function () {
}
})
}