Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TAS-2526] 🐛 Fix gifting edition selection #1968

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/NFTBook/GiftDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export default {
};
},
watch: {
value() {
this.selectedValue = this.value;
},
prefillGiftInfo: {
handler(newVal) {
this.fromName = newVal.fromName;
Expand All @@ -179,7 +182,6 @@ export default {
if (this.selectedValue === value) return;
this.selectedValue = value;
this.$emit('change', value);
this.$emit('update:value', value);
},
},
};
Expand Down
8 changes: 6 additions & 2 deletions src/components/NFTEditionSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,21 @@ export default {
return this.selectedItem?.priceLabel;
},
},
watch: {
value() {
this.selectedValue = this.value;
},
},
mounted() {
if (this.selectedValue !== this.value) {
this.$emit('update:value', this.selectedValue);
this.$emit('change', this.selectedValue);
}
},
methods: {
handleClickPriceSelectItem({ value }) {
if (this.selectedValue === value) return;
this.selectedValue = value;
this.$emit('change', value);
this.$emit('update:value', value);
this.$emit('reset-custom-price');
},
handleClickGiftButton() {
Expand Down
39 changes: 20 additions & 19 deletions src/pages/nft/class/_classId/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
class="w-full !h-[32px] !rounded-[10px] border-[#EBEBEB]"
size="tiny"
:is-disabled="isAllSoldOut"
@click="handleGiftFromEditionSelector"
@click="handleGiftButtonClick"
>
<IconGift class="w-[16px] text-dark-gray" />
<p
Expand Down Expand Up @@ -117,7 +117,7 @@
class="self-stretch"
:items="nftEditions"
:should-show-notify-button="false"
:value="defaultSelectedValue"
:value="selectedValue"
:is-all-sold-out="isAllSoldOut"
@change="handleEditionSelectChange"
@click-collect="handleCollectFromEditionSelector"
Expand Down Expand Up @@ -384,7 +384,7 @@
<NFTBookGiftDialog
:open="isGiftDialogOpen"
:items="nftEditions"
:value="defaultSelectedValue"
:value="selectedValue"
@change="handleEditionSelectChange"
@submit="handleGiftSubmit"
@close="handleGiftClose"
Expand Down Expand Up @@ -466,12 +466,10 @@ export default {
isTippingDialogOpen: false,
isAddingToCart: false,
isTriggerFromEditionSelector: false,
giftSelectedValue: 0,

trimmedCount: 10,

customPrice: 0,
selectedValue: 0,
isOpeningCheckoutPage: false,
};
},
Expand Down Expand Up @@ -892,6 +890,18 @@ export default {
classId() {
return this.$route.params.classId;
},
selectedValue: {
get() {
return Number(this.$route.query.price_index) || 0;
},
set(value) {
if (this.$route.query.price_index !== value) {
this.$router.replace({
query: { ...this.$route.query, price_index: value },
});
}
},
},
platform() {
return this.$route.query.from || NFT_BOOK_PLATFORM_LIKER_LAND;
},
Expand All @@ -913,9 +923,6 @@ export default {
isContentViewable() {
return !(this.nftIsNFTBook && !this.ownCount);
},
defaultSelectedValue() {
return this.nftEditions[this.editionPriceIndex || 0]?.value;
},
defaultCurrency() {
return this.getNFTBookStoreBookDefaultPaymentCurrency(this.classId);
},
Expand Down Expand Up @@ -1147,7 +1154,7 @@ export default {
);

if (this.nftIsNFTBook) {
this.checkTippingAvailability(this.defaultSelectedValue);
this.checkTippingAvailability(this.selectedValue);
return;
}

Expand Down Expand Up @@ -1470,11 +1477,10 @@ export default {
this.classId,
1
);
await this.handleCollectFromEdition(this.giftSelectedValue, giftInfo);
await this.handleCollectFromEdition(this.selectedValue, giftInfo);
this.isGiftDialogOpen = false;
},
handleGiftFromEditionSelector() {
this.giftSelectedValue = this.selectedValue;
handleGiftButtonClick() {
this.isGiftDialogOpen = true;
logTrackerEvent(
this,
Expand Down Expand Up @@ -1510,14 +1516,9 @@ export default {
})
);
},
async handleEditionSelectChange(selectedValue) {
handleEditionSelectChange(selectedValue) {
this.customPrice = 0;
await this.$router.replace({
query: {
...this.$route.query,
price_index: selectedValue,
},
});
this.selectedValue = selectedValue;
logTrackerEvent(
this,
'NFT',
Expand Down
4 changes: 2 additions & 2 deletions src/pages/nft/collection/_collectionId/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class="w-full !h-[32px] !rounded-[10px] border-[#EBEBEB]"
size="tiny"
:is-disabled="isAllSoldOut"
@click="handleGiftFromEditionSelector"
@click="handleGiftButtonClick"
>
<IconGift class="w-[16px] text-dark-gray" />
<p
Expand Down Expand Up @@ -627,7 +627,7 @@ export default {
await this.handleCollectFromEdition(giftInfo);
this.isGiftDialogOpen = false;
},
handleGiftFromEditionSelector() {
handleGiftButtonClick() {
this.isGiftDialogOpen = true;
logTrackerEvent(
this,
Expand Down
Loading