From 2543f09f3132fe67a4db5f09858b18eb00dbcdab Mon Sep 17 00:00:00 2001 From: Saeid Doroudi Date: Sun, 21 Jan 2024 09:23:08 +0330 Subject: [PATCH 1/2] fix: :bug: Pagination issue resolved Fixes #38 --- src/components.d.ts | 9 --------- src/mocks/handlers/color.handler.ts | 2 +- src/store/brand.store.ts | 2 +- src/store/category.store.ts | 2 +- src/store/color.store.ts | 2 +- src/store/product.store.ts | 2 +- 6 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/components.d.ts b/src/components.d.ts index 5f1065d..eaabbe4 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -25,16 +25,12 @@ declare module 'vue' { Navbar: typeof import('./components/Navbar.vue')['default'] NBadge: typeof import('naive-ui')['NBadge'] NButton: typeof import('naive-ui')['NButton'] - NCard: typeof import('naive-ui')['NCard'] NColorPicker: typeof import('naive-ui')['NColorPicker'] NConfigProvider: typeof import('naive-ui')['NConfigProvider'] - NCrad: typeof import('naive-ui')['NCrad'] NDataTable: typeof import('naive-ui')['NDataTable'] NDialogProvider: typeof import('naive-ui')['NDialogProvider'] - NDivider: typeof import('naive-ui')['NDivider'] NDrawer: typeof import('naive-ui')['NDrawer'] NDrawerContent: typeof import('naive-ui')['NDrawerContent'] - NDynamicTags: typeof import('naive-ui')['NDynamicTags'] NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem'] NIcon: typeof import('naive-ui')['NIcon'] @@ -44,15 +40,10 @@ declare module 'vue' { NLayoutSider: typeof import('naive-ui')['NLayoutSider'] NMenu: typeof import('naive-ui')['NMenu'] NMessageProvider: typeof import('naive-ui')['NMessageProvider'] - NModal: typeof import('naive-ui')['NModal'] NNotificationProvider: typeof import('naive-ui')['NNotificationProvider'] NPageHeader: typeof import('naive-ui')['NPageHeader'] NPopselect: typeof import('naive-ui')['NPopselect'] - NSelect: typeof import('naive-ui')['NSelect'] NSpace: typeof import('naive-ui')['NSpace'] - NSwitch: typeof import('naive-ui')['NSwitch'] - NTreeSelect: typeof import('naive-ui')['NTreeSelect'] - NUpload: typeof import('naive-ui')['NUpload'] ProductsManagement: typeof import('./components/Products/ProductsManagement.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] diff --git a/src/mocks/handlers/color.handler.ts b/src/mocks/handlers/color.handler.ts index 8cc40e6..a8e610d 100644 --- a/src/mocks/handlers/color.handler.ts +++ b/src/mocks/handlers/color.handler.ts @@ -4,7 +4,7 @@ import { faker } from '@faker-js/faker' import { CreatePagedResponse } from '../handlers.utility' import type { Color, ColorCreateModel } from '~/models/Color' -const colors = _.times(7, createFakeColor) +const colors = _.times(17, createFakeColor) const handlers = [ http.get('/api/Color', ({ request }) => { const response = CreatePagedResponse(request, colors) diff --git a/src/store/brand.store.ts b/src/store/brand.store.ts index f7f7769..cddb866 100644 --- a/src/store/brand.store.ts +++ b/src/store/brand.store.ts @@ -17,7 +17,7 @@ export const useBrandStore = defineStore('Brand', () => { try { const response = await brandService.getList(options) brands.value = response.items - options.pageSize = Math.trunc(response.totalCount / options.itemsPerPage) + options.pageCount = Math.ceil(response.totalCount / options.itemsPerPage) } finally { isLoading.value = false diff --git a/src/store/category.store.ts b/src/store/category.store.ts index 979e6f4..5a42001 100644 --- a/src/store/category.store.ts +++ b/src/store/category.store.ts @@ -15,7 +15,7 @@ export const useCategoryStore = defineStore('Category', () => { try { const response = await categoryService.getList(options) categories.value = response.items - options.pageSize = Math.trunc(response.totalCount / options.itemsPerPage) + options.pageCount = Math.ceil(response.totalCount / options.itemsPerPage) } finally { isLoading.value = false diff --git a/src/store/color.store.ts b/src/store/color.store.ts index 5e55755..41af284 100644 --- a/src/store/color.store.ts +++ b/src/store/color.store.ts @@ -17,7 +17,7 @@ export const useColorStore = defineStore('Color', () => { try { const response = await colorService.getList(options) colors.value = response.items - options.pageSize = Math.trunc(response.totalCount / options.itemsPerPage) + options.pageCount = Math.ceil(response.totalCount / options.pageSize) } finally { isLoading.value = false diff --git a/src/store/product.store.ts b/src/store/product.store.ts index 9cb0164..009d304 100644 --- a/src/store/product.store.ts +++ b/src/store/product.store.ts @@ -15,7 +15,7 @@ export const useProductStore = defineStore('Product', () => { try { const response = await productService.getList(options) products.value = response.items - options.pageSize = Math.trunc(response.totalCount / options.itemsPerPage) + options.pageCount = Math.ceil(response.totalCount / options.itemsPerPage) } finally { isLoading.value = false From f2040a835843110010c05cd900179a8fdec46c50 Mon Sep 17 00:00:00 2001 From: Saeid Doroudi Date: Sun, 21 Jan 2024 09:25:56 +0330 Subject: [PATCH 2/2] fix: :bug: pagination issue resolved in new pages --- src/store/customer.store.ts | 2 +- src/store/order.store.ts | 2 +- src/store/review.store.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/store/customer.store.ts b/src/store/customer.store.ts index b01c6f7..e3ab5c3 100644 --- a/src/store/customer.store.ts +++ b/src/store/customer.store.ts @@ -18,7 +18,7 @@ export const useCustomerStore = defineStore('Customer', () => { try { const response = await customerService.getList(options) customers.value = response.items - options.pageSize = Math.trunc(response.totalCount / options.itemsPerPage) + options.pageCount = Math.ceil(response.totalCount / options.itemsPerPage) } finally { isLoading.value = false diff --git a/src/store/order.store.ts b/src/store/order.store.ts index 623ce64..86d0abc 100644 --- a/src/store/order.store.ts +++ b/src/store/order.store.ts @@ -14,7 +14,7 @@ export const useOrderStore = defineStore('Order', () => { try { const response = await orderService.getOrderList(options) orders.value = response.items - options.pageSize = Math.trunc(response.totalCount / options.itemsPerPage) + options.pageCount = Math.ceil(response.totalCount / options.itemsPerPage) } finally { isLoading.value = false diff --git a/src/store/review.store.ts b/src/store/review.store.ts index a41ee32..9dffb6f 100644 --- a/src/store/review.store.ts +++ b/src/store/review.store.ts @@ -19,7 +19,7 @@ export const useReviewStore = defineStore('Review', () => { try { const response = await reviewService.getReviewList(options) reviews.value = response.items - options.pageSize = Math.trunc(response.totalCount / options.itemsPerPage) + options.pageCount = Math.ceil(response.totalCount / options.itemsPerPage) } finally { isLoading.value = false