feat(inquiries): Add pagination functionality to inquiries list table

- Import and integrate Pagination component into inquiries table
- Add allInquiries data exposure to access pagination metadata
- Expose setParams function to allow dynamic pagination updates
- Initialize default offset and limit parameters (10 items per page)
- Reset offset to 0 when applying new filters for consistent pagination
- Implement page change handler to update offset based on selected page
- Maintain filter state while navigating between pages
This commit is contained in:
AmirReza Jamali
2025-11-25 13:54:40 +03:30
parent a77bb6cccc
commit 8b795bb428
2 changed files with 25 additions and 4 deletions
@@ -38,7 +38,10 @@ const useInquiriesListPresenter = () => {
} = useForm();
useEffect(() => {
const newParams: Record<string, any> = {};
const newParams: Record<string, any> = {
offset: 0,
limit: 10,
};
for (const [key, value] of searchParams.entries()) {
newParams[key] = value;
}
@@ -50,7 +53,7 @@ const useInquiriesListPresenter = () => {
const { mutate } = useDeleteInquiry(() => setIsDeleteModalOpen(false));
const search = (data: any) => {
const newParams = { ...params, ...data };
const newParams = { ...params, ...data, offset: 0 };
const cleanedParams = deleteEmptyKeys(newParams);
const queryString = new URLSearchParams(cleanedParams).toString();
router.push(`${pathname}?${queryString}`);
@@ -65,6 +68,7 @@ const useInquiriesListPresenter = () => {
return {
columns,
inquiries: data?.data.inquiries,
allInquiries: data,
isFilterModalOpen,
setIsFilterModalOpen,
isPending,
@@ -79,6 +83,7 @@ const useInquiriesListPresenter = () => {
watch,
setFilterValue,
isMutating,
setParams,
};
};