diff --git a/src/components/EventModal/Collect/index.vue b/src/components/EventModal/Collect/index.vue
index 6f3992e46..8352f9a3d 100644
--- a/src/components/EventModal/Collect/index.vue
+++ b/src/components/EventModal/Collect/index.vue
@@ -228,29 +228,6 @@
@input="onInputCollectMessage"
/>
-
-
-
-
-
-
-
@@ -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() {
diff --git a/src/components/ShoppingCart/ListRow.vue b/src/components/ShoppingCart/ListRow.vue
index 4a36d5a4b..e90d949b4 100644
--- a/src/components/ShoppingCart/ListRow.vue
+++ b/src/components/ShoppingCart/ListRow.vue
@@ -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;
diff --git a/src/mixins/nft-collection.js b/src/mixins/nft-collection.js
index 92439637f..3108bfdc4 100644
--- a/src/mixins/nft-collection.js
+++ b/src/mixins/nft-collection.js
@@ -21,7 +21,6 @@ export default {
'getCanViewNFTBookBeforeClaimByClassId',
'getNFTCollectionInfoByCollectionId',
'getIsHideNFTBookDownload',
- 'getNFTClassPaymentPriceById',
'getNFTCollectionDefaultPaymentCurrency',
]),
classIds() {
@@ -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);
@@ -127,7 +122,6 @@ export default {
...mapActions([
'lazyGetUserInfoByAddress',
'lazyFetchNFTCollectionInfoByCollectionId',
- 'lazyFetchNFTCollectionPaymentPriceInfoByCollectionId',
]),
async lazyFetchNFTCollectionInfo() {
await catchAxiosError(
@@ -136,12 +130,5 @@ export default {
})
);
},
- async lazyFetchNFTCollectionPaymentPriceInfo() {
- await catchAxiosError(
- this.lazyFetchNFTCollectionPaymentPriceInfoByCollectionId({
- collectionId: this.collectionId,
- })
- );
- },
},
};
diff --git a/src/mixins/nft-or-collection.js b/src/mixins/nft-or-collection.js
index afe40382d..787f49222 100644
--- a/src/mixins/nft-or-collection.js
+++ b/src/mixins/nft-or-collection.js
@@ -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();
}
},
},
diff --git a/src/mixins/nft.js b/src/mixins/nft.js
index fd5910308..abb4c5446 100644
--- a/src/mixins/nft.js
+++ b/src/mixins/nft.js
@@ -104,6 +104,7 @@ export default {
'getCollectedNFTClassesByAddress',
'getCreatedNFTClassesByAddress',
'getNFTBookStorePricesByClassId',
+ 'getNFTBookStorePriceByClassIdAndIndex',
'getNFTCollectionInfoByClassId',
'getNFTBookStoreBookDefaultPaymentCurrency',
'getCanViewNFTBookBeforeClaimByClassId',
@@ -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() {
@@ -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);
}
@@ -783,8 +783,6 @@ export default {
'fetchNFTDisplayStateListByAddress',
'fetchNFTBookInfoByClassId',
'lazyFetchNFTBookInfoByClassId',
- 'fetchNFTBookPaymentPriceInfoByClassIdAndPriceIndex',
- 'lazyFetchNFTBookPaymentPriceInfoByClassIdAndPriceIndex',
'fetchNFTCollectionInfoByClassId',
]),
async fetchISCNMetadata() {
@@ -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 } = {}) {
@@ -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);
},
},
};
diff --git a/src/pages/nft/class/_classId/index.vue b/src/pages/nft/class/_classId/index.vue
index e732f50b9..1a0c0aaf1 100644
--- a/src/pages/nft/class/_classId/index.vue
+++ b/src/pages/nft/class/_classId/index.vue
@@ -827,7 +827,6 @@ export default {
this.fetchUserCollectedCount();
if (this.nftClassCollectionType === nftClassCollectionType.NFTBook) {
this.lazyFetchNFTBookInfoByClassId(this.classId).catch();
- this.lazyFetchNFTBookPaymentPriceInfoForAllEditions();
this.fetchRelatedNFTCollection({ type: 'book' });
}
const blockingPromises = [this.fetchISCNMetadata()];
@@ -1202,18 +1201,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)
diff --git a/src/pages/nft/collection/_collectionId/index.vue b/src/pages/nft/collection/_collectionId/index.vue
index 900e196ae..4c1e48339 100644
--- a/src/pages/nft/collection/_collectionId/index.vue
+++ b/src/pages/nft/collection/_collectionId/index.vue
@@ -218,7 +218,6 @@ export default {
} finally {
this.isLoading = false;
}
- this.lazyFetchNFTCollectionPaymentPriceInfo();
const { hash } = this.$route;
if (hash) {
this.$nextTick(() => {
diff --git a/src/pages/shopping-cart/book.vue b/src/pages/shopping-cart/book.vue
index 77eee337f..903ba2345 100644
--- a/src/pages/shopping-cart/book.vue
+++ b/src/pages/shopping-cart/book.vue
@@ -160,8 +160,9 @@ export default {
computed: {
...mapGetters([
'getNFTClassMetadataById',
- 'getNFTClassPaymentPriceById',
'getNFTCollectionInfoByCollectionId',
+ 'getNFTCollectionPriceByCollectionId',
+ 'getNFTBookStorePriceByClassIdAndIndex',
'shoppingCartBookProductList',
'shoppingCartBookItems',
]),
@@ -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);
},
diff --git a/src/store/modules/cart.js b/src/store/modules/cart.js
index d66cb2ef7..dc75891d5 100644
--- a/src/store/modules/cart.js
+++ b/src/store/modules/cart.js
@@ -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);
diff --git a/src/store/modules/nft.js b/src/store/modules/nft.js
index ec8c462e3..bd3f118f9 100644
--- a/src/store/modules/nft.js
+++ b/src/store/modules/nft.js
@@ -222,10 +222,8 @@ const getters = {
getNFTClassListingInfoById: state => id => state.listingInfoByClassIdMap[id],
getNFTClassMetadataById: state => id => state.metadataByClassIdMap[id],
getNFTClassOwnerInfoById: state => id => state.ownerInfoByClassIdMap[id],
- getNFTClassPaymentPriceById: state => (id, priceIndex) =>
- Number.isInteger(priceIndex)
- ? state.paymentPriceByClassIdMap[`${id}_${priceIndex}`]
- : state.paymentPriceByClassIdMap[id],
+ getNFTClassPaymentPriceById: state => id =>
+ state.paymentPriceByClassIdMap[id],
getNFTIscnRecordsById: state => id =>
state.metadataByClassIdMap[id]?.iscn_record,
getNFTClassISCNOwnerByClassId: state => id =>
@@ -252,8 +250,20 @@ const getters = {
state.nftBookStoreInfoByClassIdMap[classId],
getNFTBookStorePricesByClassId: state => classId =>
state.nftBookStoreInfoByClassIdMap[classId]?.prices || [],
+ getNFTBookStorePriceByClassIdAndIndex: state => (classId, index) => {
+ const prices = state.nftBookStoreInfoByClassIdMap[classId]?.prices || [];
+ return prices.find(p => p.index === index) || prices[index];
+ },
getNFTCollectionInfoByCollectionId: state => collectionId =>
state.nftCollectionInfoByCollectionIdMap[collectionId],
+ getNFTCollectionPriceByCollectionId: state => collectionId => {
+ const priceInDecimal =
+ state.nftCollectionInfoByCollectionIdMap[collectionId]?.priceInDecimal;
+ if (priceInDecimal !== undefined) {
+ return priceInDecimal / 100;
+ }
+ return undefined;
+ },
getNFTCollectionDefaultPaymentCurrency: state => collectionId =>
state.nftCollectionInfoByCollectionIdMap[collectionId]
?.defaultPaymentCurrency || 'USD',
@@ -823,39 +833,6 @@ const actions = {
commit(TYPES.NFT_BOOK_STORE_INFO_BY_CLASS_ID_MAP_SET, payload);
return payload;
},
- async fetchNFTBookPaymentPriceInfoByClassIdAndPriceIndex(
- { commit },
- { classId, priceIndex }
- ) {
- const {
- data: { fiatPrice, LIKEPrice },
- } = await this.$api.get(
- api.getNFTBookPaymentPrice({ classId, priceIndex })
- );
- const info = { fiatPrice, LIKEPrice };
- commit(TYPES.NFT_SET_NFT_CLASS_PAYMENT_PRICE_INFO, {
- classId,
- priceIndex,
- info,
- });
- return info;
- },
- async lazyFetchNFTBookPaymentPriceInfoByClassIdAndPriceIndex(
- { getters, dispatch },
- { classId, priceIndex }
- ) {
- let info = getters.getNFTClassPaymentPriceById(classId, priceIndex);
- if (!info) {
- info = await dispatch(
- 'fetchNFTBookPaymentPriceInfoByClassIdAndPriceIndex',
- {
- classId,
- priceIndex,
- }
- );
- }
- return info;
- },
async fetchNFTCollectionInfoByCollectionId(
{ commit, dispatch },
{ collectionId }
@@ -913,40 +890,6 @@ const actions = {
});
return list;
},
- async fetchNFTCollectionPaymentPriceInfoByCollectionId(
- { commit },
- { collectionId }
- ) {
- try {
- const {
- data: { fiatPricePrediscount, fiatPrice, LIKEPrice },
- } = await this.$api.get(api.getNFTBookPaymentPrice({ collectionId }));
- const info = { fiatPricePrediscount, fiatPrice, LIKEPrice };
- commit(TYPES.NFT_SET_NFT_CLASS_PAYMENT_PRICE_INFO, {
- collectionId,
- info,
- });
-
- return info;
- } catch (error) {
- // eslint-disable-next-line no-console
- console.error(error);
- throw error;
- }
- },
- async lazyFetchNFTCollectionPaymentPriceInfoByCollectionId(
- { getters, dispatch },
- { collectionId }
- ) {
- let info = getters.getNFTClassPaymentPriceById(collectionId);
- if (!info) {
- info = await dispatch(
- 'fetchNFTCollectionPaymentPriceInfoByCollectionId',
- { collectionId }
- );
- }
- return info;
- },
async fetchLatestAndTrendingWNFTClassIdList({ commit }) {
const trendingDate = new Date();
trendingDate.setDate(trendingDate.getDate() - 14);
diff --git a/src/util/api/index.js b/src/util/api/index.js
index 5142e3637..338ae7dc8 100644
--- a/src/util/api/index.js
+++ b/src/util/api/index.js
@@ -412,23 +412,6 @@ export const postNFTBookLIKEPurchaseEndpoint = ({
)}`;
};
-export const getNFTBookPaymentPrice = ({
- classId,
- collectionId,
- priceIndex,
-}) => {
- const qsPayload = {
- price_index: priceIndex,
- };
- return collectionId
- ? `${LIKECOIN_API_BASE}/likernft/book/collection/purchase/${collectionId}/price?${querystring.stringify(
- qsPayload
- )}`
- : `${LIKECOIN_API_BASE}/likernft/book/purchase/${classId}/price?${querystring.stringify(
- qsPayload
- )}`;
-};
-
export const getNFTCollectionInfo = ({ wallet, classId, type }) => {
const qsPayload = {
class_id: classId,