This commit is contained in:
@@ -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,
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user