Skip to content

Commit

Permalink
🔀 Merge #1842 to deploy/rinkeby
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Sep 26, 2024
2 parents 24a9737 + d737b85 commit e8f3520
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 227 deletions.
26 changes: 1 addition & 25 deletions src/components/EventModal/Collect/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -228,29 +228,6 @@
@input="onInputCollectMessage"
/>
</div>
<template v-if="nftIsNFTBook">
<Label
preset="p6"
align="left"
class="text-medium-gray mt-[12px] mb-[6px]"
:text="$t('nft_collect_modal_email')"
/>
<div
class="flex w-full py-[10px] px-[16px] gap-[12px] bg-shade-gray rounded-[12px]"
>
<IconEmail class="w-[20px] text-dark-gray" />
<input
v-model="email"
type="input"
class="w-full bg-transparent border-0 text-dark-gray focus-visible:outline-none"
:placeholder="
$t('nft_collect_modal_email_placeholder', {
name: creatorDisplayName,
})
"
/>
</div>
</template>
</section>

<section v-if="paymentMethod === undefined">
Expand Down Expand Up @@ -530,8 +507,7 @@ export default {
const notSupportedPlatforms = [];
return (
this.nftPriceInLIKE > 0 &&
!notSupportedPlatforms.includes(this.walletMethodType) &&
!(this.nftIsNFTBook && !this.isValidEmail)
!notSupportedPlatforms.includes(this.walletMethodType)
);
},
mintedFreeNFT() {
Expand Down
10 changes: 2 additions & 8 deletions src/components/ShoppingCart/ListRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,9 @@ export default {
try {
this.isFetching = true;
if (this.collectionId) {
await Promise.all([
this.lazyFetchNFTCollectionInfo(),
this.lazyFetchNFTCollectionPaymentPriceInfo(),
]);
await this.lazyFetchNFTCollectionInfo();
} else {
await Promise.all([
this.lazyFetchNFTClassAggregatedData(),
this.lazyFetchNFTBookPaymentPriceInfo(),
]);
await this.lazyFetchNFTClassAggregatedData();
}
} finally {
this.isFetching = false;
Expand Down
17 changes: 2 additions & 15 deletions src/mixins/nft-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default {
'getCanViewNFTBookBeforeClaimByClassId',
'getNFTCollectionInfoByCollectionId',
'getIsHideNFTBookDownload',
'getNFTClassPaymentPriceById',
'getNFTCollectionDefaultPaymentCurrency',
]),
classIds() {
Expand Down Expand Up @@ -98,15 +97,11 @@ export default {
},
collectionPrice() {
const priceInDecimal = this.collection?.priceInDecimal || 0;
const price =
this.getNFTClassPaymentPriceById(this.collectionId)?.fiatPrice ||
// eslint-disable-next-line prettier/prettier
(priceInDecimal / 100);
const price = priceInDecimal / 100;
return price;
},
collectionDefaultPrice() {
return this.getNFTClassPaymentPriceById(this.collectionId)
?.fiatPricePrediscount;
return this.collectionPrice;
},
collectionAvailablePriceLabel() {
return formatNumberWithUSD(this.collectionPrice);
Expand All @@ -127,7 +122,6 @@ export default {
...mapActions([
'lazyGetUserInfoByAddress',
'lazyFetchNFTCollectionInfoByCollectionId',
'lazyFetchNFTCollectionPaymentPriceInfoByCollectionId',
]),
async lazyFetchNFTCollectionInfo() {
await catchAxiosError(
Expand All @@ -136,12 +130,5 @@ export default {
})
);
},
async lazyFetchNFTCollectionPaymentPriceInfo() {
await catchAxiosError(
this.lazyFetchNFTCollectionPaymentPriceInfoByCollectionId({
collectionId: this.collectionId,
})
);
},
},
};
10 changes: 2 additions & 8 deletions src/mixins/nft-or-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,9 @@ export default {
methods: {
async lazyFetchProductInfo() {
if (this.isCollection) {
await Promise.all([
this.lazyFetchNFTCollectionInfo(),
this.lazyFetchNFTCollectionPaymentPriceInfo(),
]);
await this.lazyFetchNFTCollectionInfo();
} else {
Promise.all([
this.lazyFetchNFTClassAggregatedData(),
this.lazyFetchNFTBookPaymentPriceInfoForAllEditions(),
]);
await this.lazyFetchNFTClassAggregatedData();
}
},
},
Expand Down
68 changes: 14 additions & 54 deletions src/mixins/nft.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default {
'getCollectedNFTClassesByAddress',
'getCreatedNFTClassesByAddress',
'getNFTBookStorePricesByClassId',
'getNFTBookStorePriceByClassIdAndIndex',
'getNFTCollectionInfoByClassId',
'getNFTBookStoreBookDefaultPaymentCurrency',
'getCanViewNFTBookBeforeClaimByClassId',
Expand Down Expand Up @@ -290,11 +291,10 @@ export default {
return this.NFTPrice !== undefined && this.NFTPrice !== -1;
},
paymentInfo() {
const result =
this.getNFTClassPaymentPriceById(
this.classId,
this.editionPriceIndex
) || {};
if (this.nftIsNFTBook) {
return null;
}
const result = this.getNFTClassPaymentPriceById(this.classId);
return result;
},
nftPriceInLIKE() {
Expand All @@ -316,16 +316,16 @@ export default {
},
nftPaymentPriceInUSD() {
if (this.nftIsNFTBook) {
if (this.priceIndex !== undefined) {
const edition = this.getNFTBookStorePriceByClassIdAndIndex(
this.classId,
this.priceIndex
);
if (edition) return edition.price;
}
const result = this.getNFTBookStorePricesByClassId(this.classId);
if (!result || !result.length) return undefined;

const [price, ...prices] = result;
if (this.priceIndex !== undefined) {
const foundPrice = result.find(p => p.index === this.priceIndex);
if (foundPrice) {
return foundPrice.price;
}
}
return prices.reduce((acc, p) => Math.min(acc, p.price), price.price);
}

Expand Down Expand Up @@ -783,8 +783,6 @@ export default {
'fetchNFTDisplayStateListByAddress',
'fetchNFTBookInfoByClassId',
'lazyFetchNFTBookInfoByClassId',
'fetchNFTBookPaymentPriceInfoByClassIdAndPriceIndex',
'lazyFetchNFTBookPaymentPriceInfoByClassIdAndPriceIndex',
'fetchNFTCollectionInfoByClassId',
]),
async fetchISCNMetadata() {
Expand All @@ -805,42 +803,7 @@ export default {
},
async fetchNFTPrices() {
await catchAxiosError(
this.nftIsNFTBook
? this.fetchNFTBookPaymentPriceInfoByClassIdAndPriceIndex({
classId: this.classId,
priceIndex: this.editionPriceIndex,
})
: this.fetchNFTPaymentPriceInfoByClassId(this.classId)
);
},
async fetchNFTBookPaymentPriceInfo() {
await catchAxiosError(
this.fetchNFTBookPaymentPriceInfoByClassIdAndPriceIndex({
classId: this.classId,
priceIndex: this.editionPriceIndex,
})
);
},
async lazyFetchNFTBookPaymentPriceInfo() {
await catchAxiosError(
this.lazyFetchNFTBookPaymentPriceInfoByClassIdAndPriceIndex({
classId: this.classId,
priceIndex: this.editionPriceIndex,
})
);
},
async lazyFetchNFTBookPaymentPriceInfoForAllEditions() {
const prices = this.getNFTBookStorePricesByClassId(this.classId);
await Promise.all(
prices.map((p, i) => {
const index = p.index ?? i;
return catchAxiosError(
this.lazyFetchNFTBookPaymentPriceInfoByClassIdAndPriceIndex({
classId: this.classId,
priceIndex: index,
})
);
})
this.fetchNFTPaymentPriceInfoByClassId(this.classId)
);
},
async fetchRelatedNFTCollection({ type } = {}) {
Expand Down Expand Up @@ -1476,10 +1439,7 @@ export default {
this.isRecommendationLoading = false;
},
getEditionByIndex(index) {
const editions = this.getNFTBookStorePricesByClassId(this.classId) || {};
const edition =
editions.find(e => e.index === Number(index)) || editions[index];
return edition;
return this.getNFTBookStorePriceByClassIdAndIndex(this.classId, index);
},
},
};
12 changes: 0 additions & 12 deletions src/pages/nft/class/_classId/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1202,18 +1202,6 @@ export default {
},
})
);
// gift does not support LIKE payment for now
} else if (
!giftInfo &&
edition.price > 0 &&
this.nftPriceInLIKE > 0
) {
await this.initIfNecessary();
if (this.hasConnectedWallet) {
this.fetchUserCollectedCount();
this.walletFetchLIKEBalance();
}
this.uiToggleCollectModal({ classId: this.classId });
} else {
const customPriceInDecimal = this.customPrice
? this.formatCustomPrice(this.customPrice, edition.price)
Expand Down
1 change: 0 additions & 1 deletion src/pages/nft/collection/_collectionId/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ export default {
} finally {
this.isLoading = false;
}
this.lazyFetchNFTCollectionPaymentPriceInfo();
const { hash } = this.$route;
if (hash) {
this.$nextTick(() => {
Expand Down
22 changes: 15 additions & 7 deletions src/pages/shopping-cart/book.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ export default {
computed: {
...mapGetters([
'getNFTClassMetadataById',
'getNFTClassPaymentPriceById',
'getNFTCollectionInfoByCollectionId',
'getNFTCollectionPriceByCollectionId',
'getNFTBookStorePriceByClassIdAndIndex',
'shoppingCartBookProductList',
'shoppingCartBookItems',
]),
Expand Down Expand Up @@ -193,12 +194,19 @@ export default {
},
totalNFTPriceInUSD() {
return this.shoppingCartBookItems.reduce((totalPrice, item) => {
const priceInfo = this.getNFTClassPaymentPriceById(
item.productId,
item.classId ? item.priceIndex : undefined
);
const unitPrice =
item.customPriceInDecimal / 100 || priceInfo?.fiatPrice;
let itemPrice = 0;
if (item.collectionId) {
itemPrice = this.getNFTCollectionPriceByCollectionId(
item.collectionId
);
} else {
const edition = this.getNFTBookStorePriceByClassIdAndIndex(
item.productId,
item.classId ? item.priceIndex : undefined
);
itemPrice = edition?.price;
}
const unitPrice = item.customPriceInDecimal / 100 || itemPrice || 0;
return totalPrice + (unitPrice * item.quantity || 0);
}, 0);
},
Expand Down
23 changes: 14 additions & 9 deletions src/store/modules/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,20 @@ const getters = {
shoppingCartBookProductList: (state, getter) => {
const list = Object.values(state.shoppingCartBookProductByIdMap).filter(
item => {
const priceInfo = getter.getNFTClassPaymentPriceById(
item.productId,
item.priceIndex
);
return (
!priceInfo ||
priceInfo?.fiatPrice > 0 ||
item.customPriceInDecimal > 0
);
let itemPrice = 0;
if (item.collectionId) {
const price = getter.getNFTCollectionPriceByCollectionId(
item.collectionId
);
itemPrice = price;
} else {
const edition = getter.getNFTBookStorePriceByClassIdAndIndex(
item.classId,
item.priceIndex || 0
);
itemPrice = edition?.price;
}
return itemPrice || item.customPriceInDecimal > 0;
}
);
list.sort((a, b) => a.timestamp - b.timestamp);
Expand Down
Loading

0 comments on commit e8f3520

Please sign in to comment.