Skip to content

Commit

Permalink
pass showKeys as prop to merchant-details child and use emit to toggle (
Browse files Browse the repository at this point in the history
#105)

previously, index and its child compoment merchant-details had their own
booleans and their values were not synched. Using a prop avoids this
problem
  • Loading branch information
PatMulligan authored Oct 25, 2024
1 parent db35538 commit 7a3b144
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion static/components/merchant-details/merchant-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
>
</q-item-section>
</q-item>
<q-item @click="toggleMerchantKeys" clickable v-close-popup>
<q-item @click="toggleShowKeys" clickable v-close-popup>
<q-item-section>
<q-item-label v-if="!showKeys">Show Keys</q-item-label>
<q-item-label v-else>Hide Keys</q-item-label>
Expand Down
8 changes: 3 additions & 5 deletions static/components/merchant-details/merchant-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ async function merchantDetails(path) {
const template = await loadTemplateAsync(path)
Vue.component('merchant-details', {
name: 'merchant-details',
props: ['merchant-id', 'adminkey', 'inkey'],
props: ['merchant-id', 'adminkey', 'inkey','showKeys'],
template,

data: function () {
return {
showKeys: false
}
},
methods: {
toggleMerchantKeys: async function () {
this.showKeys = !this.showKeys
this.$emit('show-keys', this.showKeys)
toggleShowKeys: async function () {
this.$emit('toggle-show-keys')
},

republishMerchantData: async function () {
Expand Down
4 changes: 2 additions & 2 deletions static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const merchant = async () => {
showImportKeysDialog: async function () {
this.importKeyDialog.show = true
},
toggleMerchantKeys: function (value) {
this.showKeys = value
toggleShowKeys: function () {
this.showKeys = !this.showKeys
},
toggleMerchantState: async function () {
const merchant = await this.getMerchant()
Expand Down
3 changes: 2 additions & 1 deletion templates/nostrmarket/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
:merchant-id="merchant.id"
:inkey="g.user.wallets[0].inkey"
:adminkey="g.user.wallets[0].adminkey"
@show-keys="toggleMerchantKeys"
:show-keys="showKeys"
@toggle-show-keys="toggleShowKeys"
@merchant-deleted="handleMerchantDeleted"
></merchant-details>
</div>
Expand Down

0 comments on commit 7a3b144

Please sign in to comment.