pagination
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
hamid zarghami
2026-06-29 09:45:56 +03:30
parent 2a5905b35f
commit 7601368bd3
6 changed files with 87 additions and 23 deletions
+10 -4
View File
@@ -1,4 +1,4 @@
import { type FC } from 'react'
import { type FC, useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import Table from '@/components/Table'
import Filters from '@/components/Filters'
@@ -17,7 +17,6 @@ const OrdersList: FC = () => {
apiParams,
handleFiltersChange,
handlePageChange,
limit,
} = useOrderFilters()
const { data: ordersData, isLoading } = useGetOrders(apiParams)
@@ -26,7 +25,14 @@ const OrdersList: FC = () => {
const columns = getOrderTableColumns({ t })
const filterFields = useOrderFiltersFields()
const totalPages = Math.ceil(orders.length / limit) || 1
const totalPages = ordersData?.meta?.totalPages || 1
const effectivePage = Math.min(currentPage, totalPages)
useEffect(() => {
if (currentPage > totalPages) {
handlePageChange(totalPages)
}
}, [currentPage, totalPages, handlePageChange])
return (
<div className='mt-5'>
@@ -48,7 +54,7 @@ const OrdersList: FC = () => {
data={orders as (Order & RowDataType)[]}
isloading={isLoading}
pagination={{
currentPage,
currentPage: effectivePage,
totalPages,
onPageChange: handlePageChange,
}}