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:
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user