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

🔧 bsx/snek offers composition api #6633

Merged
merged 6 commits into from
Aug 10, 2023
Merged
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
Prev Previous commit
🔧 refresh button on MyOffer
  • Loading branch information
roiLeo committed Aug 10, 2023
commit 470fa10b8c1565ea21bcbaf11ce8cfb4aa543034
37 changes: 21 additions & 16 deletions components/bsx/Offer/MyOffer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
{{ $t('myOffer.bsxTitle') }}
</h1>
</div>
<NeoSelect v-model="selectedStatus">
<option
v-for="option in getUniqType()"
:key="option.type"
:value="option.type">
{{ option.value }}
</option>
</NeoSelect>
<div class="is-flex is-justify-content-space-between is-align-items-center">
<NeoSelect v-model="selectedStatus">
<option
v-for="option in getUniqType()"
:key="option.type"
:value="option.type">
{{ option.value }}
</option>
</NeoSelect>
<NeoButton
no-shadow
size="medium"
icon-left="refresh"
@click.native="refresh" />
</div>
<Loader v-model="isLoading" :status="status" />
<NeoTable :data="displayOffers(offers)">
<NeoTableColumn v-slot="props" :label="$t('nft.offer.item')" sortable>
Expand Down Expand Up @@ -109,8 +116,8 @@ const selectedStatus = ref<AllOfferStatusType>(AllOfferStatusType.ALL)

withDefaults(
defineProps<{
address: string
hideHeading: boolean
address?: string
hideHeading?: boolean
}>(),
{
address: '',
Expand All @@ -132,7 +139,7 @@ const getUniqType = () => {
return [{ type: AllOfferStatusType.ALL, value: 'All' }, ...singleEventList]
}

const fetchMyOffers = async () => {
const { refresh } = useLazyAsyncData('offers', async () => {
if (!targetAddress.value) {
return
}
Expand All @@ -149,9 +156,7 @@ const fetchMyOffers = async () => {
} catch (e) {
$consola.error(e)
}
}

watchEffect(async () => await fetchMyOffers())
})

// doesn't need emit?
// const emit = defineEmits(['offersIncoming'])
Expand Down Expand Up @@ -196,7 +201,7 @@ const onClick = async (offer: Offer, withdraw: boolean) => {
const { caller, nft } = offer
const { id: collectionId, item } = tokenIdToRoute(nft.id)
isLoading.value = true
await submit(caller, item, collectionId, withdraw, fetchMyOffers)
await submit(caller, item, collectionId, withdraw, refresh)
}

const displayOffers = (offers: Offer[]) => {
Expand Down Expand Up @@ -239,7 +244,7 @@ const calcExpirationTime = (expirationBlock: number): string => {
}

watch(accountId, () => {
fetchMyOffers()
refresh()
})
</script>

Expand Down