This commit is contained in:
Oscar
2026-06-04 13:42:20 +03:00
parent dd86c564c4
commit 40a281b87e
4 changed files with 46 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
import type { Item, PaginatedItems } from '~/services/api'
import type { Item } from '~/services/api'
import { ref } from 'vue'
import { Api } from '~/services/api'
@@ -8,6 +8,8 @@ export function useItems() {
const leftItems = ref<Item[]>([])
const rightItems = ref<Item[]>([])
const rightItemsTotal = ref(0)
const leftItemsTotal = ref(0)
const leftSearch = ref('')
const rightSearch = ref('')
const leftLoading = ref(false)
@@ -27,13 +29,14 @@ export function useItems() {
return
leftLoading.value = true
try {
const data: PaginatedItems = await client.api.itemsList({
const data = await client.api.itemsList({
page: leftPage.value,
limit: 20,
...(leftSearch.value ? { search: leftSearch.value } : {}),
})
leftItems.value.push(...(data.data ?? []))
leftHasMore.value = data.hasMore ?? false
leftItemsTotal.value = data.total || 0
leftPage.value++
}
finally {
@@ -51,13 +54,14 @@ export function useItems() {
return
rightLoading.value = true
try {
const data: PaginatedItems = await client.api.itemsSelectedList({
const data = await client.api.itemsSelectedList({
page: rightPage.value,
limit: 20,
...(rightSearch.value ? { search: rightSearch.value } : {}),
})
rightItems.value.push(...(data.data ?? []))
rightHasMore.value = data.hasMore ?? false
rightItemsTotal.value = data.total || 0
rightPage.value++
}
finally {
@@ -86,7 +90,9 @@ export function useItems() {
return {
leftItems,
leftItemsTotal,
rightItems,
rightItemsTotal,
leftSearch,
rightSearch,
leftLoading,