Skip to content

Commit

Permalink
✨ Support batch collect (#1137)
Browse files Browse the repository at this point in the history
* 🚧 Add UI for batch collect

* 👔 Remove shopping cart entry

* 🚸 Move collect all button to the side

* 🚸 Prevent collect all while loading

* 🚸 Filter WNFT batch collected in portfolio

* 💬 Update text

* 🎨 FIx possible try-catch issue

* 💄 Move insufficient balance label

* 🚸 Prevent closing tx dialog in batch purchase

* 🐛 Fix batch collect message handling

* 💬 Use backpack for shopping cart

---------

Co-authored-by: Edmond Yu <[email protected]>
  • Loading branch information
nwingt and edmondyu authored Jun 28, 2023
1 parent 82b2c56 commit e7f7436
Show file tree
Hide file tree
Showing 21 changed files with 822 additions and 51 deletions.
3 changes: 3 additions & 0 deletions src/assets/icons/local-mall.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 21 additions & 8 deletions src/components/CardV2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,30 @@ export default class Card extends Vue {
@Prop({ default: false })
readonly isDark!: boolean;
@Prop({ default: false })
readonly isOutline!: boolean;
get rootClasses() {
return [
this.isDark
? 'bg-like-green bg-gradient-to-r from-transparent to-like-cyan-translucent'
: 'bg-white',
const classes = [
'rounded-[24px]',
{
'text-like-cyan-pale': this.isDark,
'px-[24px] py-[32px]': this.hasPadding,
},
{ 'px-[24px] py-[32px]': this.hasPadding },
];
if (this.isOutline) {
classes.push('border');
if (this.isDark) {
classes.push('border-like-cyan-pale');
} else {
classes.push('border-gray-d8');
}
} else if (this.isDark) {
classes.push(
'bg-like-green bg-gradient-to-r from-transparent to-like-cyan-translucent',
'text-like-cyan-pale'
);
} else {
classes.push('bg-white');
}
return classes;
}
}
</script>
2 changes: 2 additions & 0 deletions src/components/EventModal/Collect/MethodButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
@click="handleClick"
>
<template #prepend>
<slot v-if="$slots.prepend" name="prepend" />
<EventModalCollectMethodIcon
v-else
class="w-[24px] h-[24px] text-like-green"
:type="type"
/>
Expand Down
96 changes: 90 additions & 6 deletions src/components/EventModal/Collect/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
/>
</client-only>
</transition>
<template v-if="isCompleted">
<Label
v-if="isAddedToShoppingCart"
preset="p5"
align="center"
>{{ $t('nft_collect_modal_added_to_shopping_cart_description', { nft: NFTName }) }}</Label>
<template v-else-if="isCompleted">
<Label class="text-medium-gray mt-[12px] flex-nowrap" preset="h6" align="center">
<i18n
:path="
Expand All @@ -61,7 +66,7 @@
</i18n>
</Label>
<div
v-if="!isFollowPromptStateDefault"
v-if="!isFollowPromptStateDefault && !isBatchCollect"
class="flex justify-center items-center mt-[16px] px-[12px] rounded-[48px] border-[1px] border-medium-gray"
>
<NFTMessageIdentity
Expand Down Expand Up @@ -131,9 +136,20 @@
#button
>
<ButtonV2
v-if="isBatchCollect"
preset="outline"
:text="$t('nft_details_page_button_view_portfolio')"
:to="localeLocation({ name: 'id', params: { id: getAddress }, query: { tab: 'collected' } })"
@click.native="handleClose"
>
<template #prepend>
<IconEye class="w-[20px]" />
</template>
</ButtonV2>
<ButtonV2
v-else
preset="outline"
:text="$t('nft_details_page_button_view_details')"
class="mr-[12px]"
@click="goToNFTDetails"
>
<template #prepend>
Expand All @@ -142,7 +158,20 @@
</ButtonV2>
</template>

<template v-if="!uiTxNFTStatus">
<template v-else-if="isAddedToShoppingCart" #button>
<ButtonV2
preset="secondary"
:text="$t('nft_collect_modal_go_to_shopping_cart_button')"
:to="localeLocation({ name: 'shopping-cart' })"
@click.native="handleClose"
>
<template #prepend>
<LocalMallIcon class="w-[20px]" />
</template>
</ButtonV2>
</template>

<template v-if="!isAddedToShoppingCart && !uiTxNFTStatus">
<section
v-if="paymentMethod === undefined"
class="flex flex-col items-start mb-[28px]"
Expand Down Expand Up @@ -242,6 +271,26 @@
</a>
</div>
</li>
<!--
<li v-if="isShowAddToShoppingCartButton">
<Separator class="mx-auto" />
<EventModalCollectMethodButton
:title="(
hasAddedToShoppingCart
? $t('nft_collect_modal_added_to_cart')
: $tc('nft_collect_modal_add_to_cart', shoppingCartQuantity, { count: shoppingCartQuantity })
)"
type="crypto"
:price="formattedNFTPriceInLIKE"
:is-disabled="hasAddedToShoppingCart"
@click="handleAddToCart"
>
<template #prepend>
<LocalMallIcon :class="['w-[24px]', { 'text-like-green': !hasAddedToShoppingCart }]" />
</template>
</EventModalCollectMethodButton>
</li>
-->
</ul>
</section>
<section v-else>
Expand All @@ -255,6 +304,8 @@
import { mapActions, mapGetters } from 'vuex';
import modelLoadingImage from '~/assets/images/nft/model-loading.png';
import LocalMallIcon from '~/assets/icons/local-mall.svg?inline';
import { logTrackerEvent } from '~/util/EventLogger';
import { formatNumberWithLIKE, oscillate } from '~/util/ui';
Expand All @@ -271,6 +322,9 @@ export default {
filters: {
formatNumberWithLIKE,
},
components: {
LocalMallIcon,
},
mixins: [clipboardMixin, nftMixin],
props: {
isOpen: {
Expand Down Expand Up @@ -317,11 +371,13 @@ export default {
isFollowPromptUpdating: false,
modelExposure: 0,
animationTimer: null,
isAddedToShoppingCart: false,
};
},
computed: {
...mapGetters([
'getAddress',
'getShoppingCartNFTClassQuantity',
'walletFollowees',
'walletIsLoggingIn',
'walletInteractedCreators',
Expand All @@ -332,9 +388,14 @@ export default {
developerMode() {
return !!this.$route.query.debug;
},
isBatchCollect() {
return Array.isArray(this.uiTxTargetClassId);
},
classId() {
// Alias for NFT mixin
return this.uiTxTargetClassId;
return this.isBatchCollect
? this.uiTxTargetClassId[0]
: this.uiTxTargetClassId;
},
headerText() {
return this.paymentMethod === undefined ||
Expand All @@ -344,7 +405,8 @@ export default {
},
isShowCloseButton() {
return (
this.paymentMethod === undefined ||
(this.paymentMethod === undefined &&
!this.getRouteBaseName(this.$route) === 'shopping-cart') ||
this.uiTxNFTStatus === 'completed' ||
this.uiTxNFTStatus === 'processing_non_blocking'
);
Expand Down Expand Up @@ -426,6 +488,15 @@ export default {
purchaseLIKELink() {
return 'https://faucet.like.co/purchase';
},
isShowAddToShoppingCartButton() {
return this.canPayByLIKE && !this.nftIsUseListingPrice;
},
shoppingCartQuantity() {
return this.getShoppingCartNFTClassQuantity(this.classId);
},
hasAddedToShoppingCart() {
return this.shoppingCartQuantity > 0;
},
},
watch: {
isOpen(isOpen) {
Expand Down Expand Up @@ -483,6 +554,7 @@ export default {
'walletFollowCreator',
'walletAddInteractedCreator',
'walletUnfollowCreator',
'addNFTClassToShoppingCart',
]),
startExposureAnimation(time = performance.now(), lastTime = time) {
if (this.isProcessing) {
Expand All @@ -508,6 +580,7 @@ export default {
this.paymentMethod = undefined;
this.justCollectedNFTId = undefined;
this.memo = '';
this.isAddedToShoppingCart = false;
// Mixin
this.userCollectedCount = undefined;
Expand Down Expand Up @@ -564,6 +637,17 @@ export default {
}
}
},
handleAddToCart() {
logTrackerEvent(
this,
'NFT',
'nft_collect_modal_click_add_to_cart',
this.classId,
1
);
this.addNFTClassToShoppingCart({ classId: this.classId });
this.isAddedToShoppingCart = true;
},
goToNFTDetails() {
this.$router.push(
this.localeLocation({
Expand Down
2 changes: 2 additions & 0 deletions src/components/NFTPortfolio/MainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
</div>
</div>

<slot name="before-grid" />

<NFTPagePrimitiveDisclaimer
v-if="isPortfolioOtherFilterActive"
class="w-full"
Expand Down
7 changes: 5 additions & 2 deletions src/components/NFTPortfolio/SubscriptionForm.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div class="flex flex-col items-center gap-[24px] text-medium-gray bg-shade-gray rounded-[24px] px-[32px] py-[24px]">
<CardV2
class="flex flex-col items-center gap-[24px] text-medium-gray"
:is-outline="true"
>
<Label
preset="h4"
align="center"
Expand Down Expand Up @@ -88,7 +91,7 @@
</Label>
<p class="text-center underline text-[10px] text-medium-gray mt-[32px] cursor-pointer" @click="handleClickResend">{{ $t('portfolio_subscription_verify_sendAgain') }}</p>
</Dialog>
</div>
</CardV2>
</template>

<script>
Expand Down
Loading

0 comments on commit e7f7436

Please sign in to comment.