From 3270c1f4be42e6398df048a9a7c336089bb327fe Mon Sep 17 00:00:00 2001 From: hassnian Date: Sun, 10 Sep 2023 10:17:47 +0500 Subject: [PATCH 001/111] added: single and multiple list cart --- .../common/listingCart/ListingCartItem.vue | 89 ------------------- .../common/listingCart/ListingCartModal.vue | 65 ++------------ .../multipleItemsCart/ListingCartItem.vue | 63 +++++++++++++ .../ListingCartMultipleItemsCart.vue | 45 ++++++++++ .../shared/ListingCartFloorPrice.vue | 57 ++++++++++++ .../shared/ListingCartItemDetails.vue | 53 +++++++++++ .../{ => shared}/ListingCartPriceInput.vue | 20 ++++- .../ListingCartSingleItemCart.vue | 65 ++++++++++++++ locales/en.json | 4 +- 9 files changed, 313 insertions(+), 148 deletions(-) delete mode 100644 components/common/listingCart/ListingCartItem.vue create mode 100644 components/common/listingCart/multipleItemsCart/ListingCartItem.vue create mode 100644 components/common/listingCart/multipleItemsCart/ListingCartMultipleItemsCart.vue create mode 100644 components/common/listingCart/shared/ListingCartFloorPrice.vue create mode 100644 components/common/listingCart/shared/ListingCartItemDetails.vue rename components/common/listingCart/{ => shared}/ListingCartPriceInput.vue (82%) create mode 100644 components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue diff --git a/components/common/listingCart/ListingCartItem.vue b/components/common/listingCart/ListingCartItem.vue deleted file mode 100644 index 7d58f08b94..0000000000 --- a/components/common/listingCart/ListingCartItem.vue +++ /dev/null @@ -1,89 +0,0 @@ - - - - diff --git a/components/common/listingCart/ListingCartModal.vue b/components/common/listingCart/ListingCartModal.vue index d68ed208e0..8f25d33ec2 100644 --- a/components/common/listingCart/ListingCartModal.vue +++ b/components/common/listingCart/ListingCartModal.vue @@ -18,6 +18,7 @@ icon="close" @click.native="preferencesStore.listingCartModalOpen = false" /> +
@@ -31,56 +32,11 @@ class="identity-name-font-weight-regular" data-testid="item-creator" />
-
Set All To
-
- {{ $t('listingCart.collectionFloorPrice') }} - {{ (floorPricePercentAdjustment * 100 - 100).toFixed(0) }}% -
-
- - - -
-
-Or-
-
{{ $t('listingCart.fixedPrice') }}
- -
-
- + + +
+
{{ $t('listingCart.potentialEarnings') }} @@ -107,7 +63,6 @@ + diff --git a/components/common/listingCart/multipleItemsCart/ListingCartMultipleItemsCart.vue b/components/common/listingCart/multipleItemsCart/ListingCartMultipleItemsCart.vue new file mode 100644 index 0000000000..6f22529e63 --- /dev/null +++ b/components/common/listingCart/multipleItemsCart/ListingCartMultipleItemsCart.vue @@ -0,0 +1,45 @@ + + + + + diff --git a/components/common/listingCart/shared/ListingCartFloorPrice.vue b/components/common/listingCart/shared/ListingCartFloorPrice.vue new file mode 100644 index 0000000000..42e01e30ea --- /dev/null +++ b/components/common/listingCart/shared/ListingCartFloorPrice.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/components/common/listingCart/shared/ListingCartItemDetails.vue b/components/common/listingCart/shared/ListingCartItemDetails.vue new file mode 100644 index 0000000000..fd3ff8cdc3 --- /dev/null +++ b/components/common/listingCart/shared/ListingCartItemDetails.vue @@ -0,0 +1,53 @@ + + + + + diff --git a/components/common/listingCart/ListingCartPriceInput.vue b/components/common/listingCart/shared/ListingCartPriceInput.vue similarity index 82% rename from components/common/listingCart/ListingCartPriceInput.vue rename to components/common/listingCart/shared/ListingCartPriceInput.vue index acc5d210b4..bb2e125803 100644 --- a/components/common/listingCart/ListingCartPriceInput.vue +++ b/components/common/listingCart/shared/ListingCartPriceInput.vue @@ -1,6 +1,8 @@ @@ -41,17 +34,14 @@ - - diff --git a/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue b/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue index 1a2bff6e01..4361bdfdaf 100644 --- a/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue +++ b/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue @@ -23,13 +23,9 @@
{{ $t('listingCart.chooseAPrice') }}
- + - +
@@ -39,10 +35,29 @@ import ListingCartItemDetails from '../shared/ListingCartItemDetails.vue' import ListingCartFloorPrice from '../shared/ListingCartFloorPrice.vue' import ListingCartPriceInput from '../shared/ListingCartPriceInput.vue' +const emit = defineEmits([ + 'update:fixedPrice', + 'update:floorPricePercentAdjustment', +]) + +const props = defineProps<{ + fixedPrice: number | null + floorPricePercentAdjustment: number +}>() + +const fixedPrice = useVModel(props, 'fixedPrice', emit, { + eventName: 'update:fixedPrice', +}) +const floorPricePercentAdjustment = useVModel( + props, + 'floorPricePercentAdjustment', + emit, + { eventName: 'update:floorPricePercentAdjustment' } +) + const listingCartStore = useListingCartStore() const { chainSymbol } = useChain() -const fixedPrice = ref(null) const item = computed(() => listingCartStore.itemsInChain[0]) const itemPrice = computed(() => @@ -53,13 +68,4 @@ const collectionPrice = computed(() => ? `${item.value.collection.floor} ${chainSymbol.value}` : '--' ) - -function setFixedPrice() { - listingCartStore.setFixedPrice(fixedPrice.value) - fixedPrice.value = null -} - -function setFloorPrice(value?: number) { - listingCartStore.setFloorPrice(value) -} From cb8460adbada06083ab6a8a59612d2d3e1320e41 Mon Sep 17 00:00:00 2001 From: hassnian Date: Sun, 10 Sep 2023 15:32:53 +0500 Subject: [PATCH 003/111] fix: fixed price not updating --- .../common/listingCart/ListingCartModal.vue | 34 ++++++++++--------- .../ListingCartMultipleItemsCart.vue | 14 +++++--- .../ListingCartSingleItemCart.vue | 14 ++++++-- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/components/common/listingCart/ListingCartModal.vue b/components/common/listingCart/ListingCartModal.vue index 41923caedc..d7ca6afe16 100644 --- a/components/common/listingCart/ListingCartModal.vue +++ b/components/common/listingCart/ListingCartModal.vue @@ -35,9 +35,13 @@ + v-bind.sync="cartData" + @setFixedPrice="setFixedPrice" /> - +
(null) - const cartData = ref<{ - fixedPrice: number | null + fixedPrice?: number | string floorPricePercentAdjustment: number }>({ - fixedPrice: null, + fixedPrice: undefined, floorPricePercentAdjustment: 1, }) -watch( - () => cartData.value.fixedPrice, - (value) => { - listingCartStore.setFixedPrice(value) - } -) +function setFixedPrice() { + const fixedPrice = cartData.value.fixedPrice + + const rate = + fixedPrice === undefined || fixedPrice === null || fixedPrice === '' + ? null + : Number(fixedPrice) + + listingCartStore.setFixedPrice(rate) +} watch( () => cartData.value.floorPricePercentAdjustment, @@ -113,10 +119,6 @@ watch( } ) -// function setFixedPrice(price) { -// cartData.value.fixedPrice = null -// } - const fiatStore = useFiatStore() const priceUSD = computed(() => calculateExactUsdFromToken( diff --git a/components/common/listingCart/multipleItemsCart/ListingCartMultipleItemsCart.vue b/components/common/listingCart/multipleItemsCart/ListingCartMultipleItemsCart.vue index 579c62e9be..26bd97877b 100644 --- a/components/common/listingCart/multipleItemsCart/ListingCartMultipleItemsCart.vue +++ b/components/common/listingCart/multipleItemsCart/ListingCartMultipleItemsCart.vue @@ -10,9 +10,9 @@
{{ $t('listingCart.fixedPrice') }}
@@ -33,12 +33,13 @@ import ListingCartFloorPrice from '../shared/ListingCartFloorPrice.vue' const emit = defineEmits([ 'update:fixedPrice', 'update:floorPricePercentAdjustment', + 'setFixedPrice', ]) const listingCartStore = useListingCartStore() const props = defineProps<{ - fixedPrice: number | null + fixedPrice?: number | string floorPricePercentAdjustment: number }>() @@ -49,8 +50,13 @@ const floorPricePercentAdjustment = useVModel( { eventName: 'update:floorPricePercentAdjustment' } ) +const fixedPrice = useVModel(props, 'fixedPrice', emit, { + eventName: 'update:fixedPrice', +}) + function setFixedPrice(value) { - emit('update:fixedPrice', value) + emit('setFixedPrice', value) + emit('update:fixedPrice', '') } diff --git a/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue b/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue index 4361bdfdaf..37f6edc039 100644 --- a/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue +++ b/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue @@ -25,7 +25,10 @@ - +
@@ -38,16 +41,18 @@ import ListingCartPriceInput from '../shared/ListingCartPriceInput.vue' const emit = defineEmits([ 'update:fixedPrice', 'update:floorPricePercentAdjustment', + 'setFixedPrice', ]) const props = defineProps<{ - fixedPrice: number | null + fixedPrice?: number | string floorPricePercentAdjustment: number }>() const fixedPrice = useVModel(props, 'fixedPrice', emit, { eventName: 'update:fixedPrice', }) + const floorPricePercentAdjustment = useVModel( props, 'floorPricePercentAdjustment', @@ -68,4 +73,9 @@ const collectionPrice = computed(() => ? `${item.value.collection.floor} ${chainSymbol.value}` : '--' ) + +watch( + () => props.fixedPrice, + (value) => emit('setFixedPrice', value) +) From 7319af521c1406581ca860fbeb2b5bed7e982d60 Mon Sep 17 00:00:00 2001 From: hassnian Date: Sun, 10 Sep 2023 16:31:18 +0500 Subject: [PATCH 004/111] fix: format token amount --- .../singleItemCart/ListingCartSingleItemCart.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue b/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue index 37f6edc039..cf597a059b 100644 --- a/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue +++ b/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue @@ -37,6 +37,7 @@ import { useListingCartStore } from '@/stores/listingCart' import ListingCartItemDetails from '../shared/ListingCartItemDetails.vue' import ListingCartFloorPrice from '../shared/ListingCartFloorPrice.vue' import ListingCartPriceInput from '../shared/ListingCartPriceInput.vue' +import { formatBalance } from '@polkadot/util' const emit = defineEmits([ 'update:fixedPrice', @@ -61,17 +62,21 @@ const floorPricePercentAdjustment = useVModel( ) const listingCartStore = useListingCartStore() -const { chainSymbol } = useChain() +const { chainSymbol, decimals } = useChain() const item = computed(() => listingCartStore.itemsInChain[0]) const itemPrice = computed(() => - !item.value.price ? `${item.value.price} ${chainSymbol.value}` : '--' + formatBalance(item.value.price, { + decimals: decimals.value, + withUnit: chainSymbol.value, + }) ) const collectionPrice = computed(() => - !!item.value.collection.floor - ? `${item.value.collection.floor} ${chainSymbol.value}` - : '--' + formatBalance(item.value.collection.floor, { + decimals: decimals.value, + withUnit: chainSymbol.value, + }) ) watch( From 8e2d0f4f92468b539f9cbfe96f2f3d2a342b025c Mon Sep 17 00:00:00 2001 From: hassnian Date: Sun, 10 Sep 2023 16:34:42 +0500 Subject: [PATCH 005/111] fix: format with blank --- .../ListingCartSingleItemCart.vue | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue b/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue index cf597a059b..67465021ac 100644 --- a/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue +++ b/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue @@ -66,19 +66,21 @@ const { chainSymbol, decimals } = useChain() const item = computed(() => listingCartStore.itemsInChain[0]) -const itemPrice = computed(() => - formatBalance(item.value.price, { - decimals: decimals.value, - withUnit: chainSymbol.value, - }) -) +const itemPrice = computed(() => formatWithBlank(item.value.price)) + const collectionPrice = computed(() => - formatBalance(item.value.collection.floor, { - decimals: decimals.value, - withUnit: chainSymbol.value, - }) + formatWithBlank(item.value.collection.floor) ) +const formatWithBlank = (value) => { + return value + ? formatBalance(value, { + decimals: decimals.value, + withUnit: chainSymbol.value, + }) + : '--' +} + watch( () => props.fixedPrice, (value) => emit('setFixedPrice', value) From 5ed743caa7b4c383c81cd47afe8ebaa1098d0f05 Mon Sep 17 00:00:00 2001 From: hassnian Date: Sun, 10 Sep 2023 16:51:23 +0500 Subject: [PATCH 006/111] fix: style missing --- .../listingCart/multipleItemsCart/ListingCartItem.vue | 9 --------- .../listingCart/shared/ListingCartItemDetails.vue | 10 +++++++++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/components/common/listingCart/multipleItemsCart/ListingCartItem.vue b/components/common/listingCart/multipleItemsCart/ListingCartItem.vue index db8bbc9007..925cc2cf37 100644 --- a/components/common/listingCart/multipleItemsCart/ListingCartItem.vue +++ b/components/common/listingCart/multipleItemsCart/ListingCartItem.vue @@ -52,12 +52,3 @@ const floor = computed(() => }) ) - diff --git a/components/common/listingCart/shared/ListingCartItemDetails.vue b/components/common/listingCart/shared/ListingCartItemDetails.vue index fd3ff8cdc3..1d5efaf0ad 100644 --- a/components/common/listingCart/shared/ListingCartItemDetails.vue +++ b/components/common/listingCart/shared/ListingCartItemDetails.vue @@ -50,4 +50,12 @@ onMounted(() => { }) - + From 45bba47b4009f6e4ae6421e150f9ce50d71647c1 Mon Sep 17 00:00:00 2001 From: hassnian Date: Sun, 10 Sep 2023 17:02:23 +0500 Subject: [PATCH 007/111] fix: single cart paddings --- .../singleItemCart/ListingCartSingleItemCart.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue b/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue index 67465021ac..256822826c 100644 --- a/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue +++ b/components/common/listingCart/singleItemCart/ListingCartSingleItemCart.vue @@ -1,5 +1,5 @@