From ac0f935e8305b39aff3017cf9d2835a93a60bc2b Mon Sep 17 00:00:00 2001 From: james-tran-3005 Date: Fri, 22 Nov 2024 13:10:00 +0700 Subject: [PATCH] fix(portal): fix buyer management pagination doesn't work properly --- .../src/hooks/product/index.ts | 1 + .../src/pages/Buyer/index.tsx | 25 ++++++++----------- .../src/stores/buyer.store.tsx | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/kraken-app/kraken-app-portal/src/hooks/product/index.ts b/kraken-app/kraken-app-portal/src/hooks/product/index.ts index 088145e1..946b71c3 100644 --- a/kraken-app/kraken-app-portal/src/hooks/product/index.ts +++ b/kraken-app/kraken-app-portal/src/hooks/product/index.ts @@ -575,6 +575,7 @@ export const useGetBuyerList = ( queryFn: () => getBuyerList(productId, params), enabled: Boolean(productId) && Boolean(params.envId), select: (data) => data?.data, + staleTime: STALE_TIME, }); }; diff --git a/kraken-app/kraken-app-portal/src/pages/Buyer/index.tsx b/kraken-app/kraken-app-portal/src/pages/Buyer/index.tsx index 64093431..4f361df5 100644 --- a/kraken-app/kraken-app-portal/src/pages/Buyer/index.tsx +++ b/kraken-app/kraken-app-portal/src/pages/Buyer/index.tsx @@ -13,7 +13,7 @@ import { useAppStore } from "@/stores/app.store"; import { useBuyerStore } from "@/stores/buyer.store"; import { IBuyer } from "@/utils/types/component.type"; import { Button, Flex, Popconfirm, Table, notification } from "antd"; -import { get, isEmpty, omitBy } from "lodash"; +import { get } from "lodash"; import { useEffect, useMemo, useRef } from "react"; import { useBoolean } from "usehooks-ts"; import { ContentTime } from "../NewAPIMapping/components/DeployHistory/ContentTime"; @@ -26,7 +26,7 @@ const Buyer = () => { const { params, setParams, resetParams } = useBuyerStore(); const { data: dataList, isLoading } = useGetBuyerList( currentProduct, - omitBy(params, isEmpty) + params ); const { value: isModalVisible, @@ -180,18 +180,15 @@ const Buyer = () => {
{ - setParams({ page: page - 1, size: pageSize }); - }, - } - } + pagination={{ + current: dataList?.page + 1, + total: dataList?.total, + size: dataList?.size, + showSizeChanger: true, + onChange: (page, pageSize) => { + setParams({ page: page - 1, size: pageSize }); + }, + }} dataSource={dataList?.data} columns={columns} scroll={{ y: get(size, "height", 0) - 60, x: "auto" }} diff --git a/kraken-app/kraken-app-portal/src/stores/buyer.store.tsx b/kraken-app/kraken-app-portal/src/stores/buyer.store.tsx index b3a0f490..6d67b4ca 100644 --- a/kraken-app/kraken-app-portal/src/stores/buyer.store.tsx +++ b/kraken-app/kraken-app-portal/src/stores/buyer.store.tsx @@ -15,7 +15,7 @@ type BuyerStore = { const DEFAULT_PARAMS = { page: 0, - size: 50, + size: 20, orderBy: "createdAt", direction: "DESC", };