feat(pagination): implement hybrid pagination across multiple components
- Introduced a new `useHybridPagination` hook to manage pagination logic, enhancing data fetching and navigation. - Updated various components including `useAdminsPresenter`, `useCompanyListPresenter`, `useCustomerListPresenter`, and others to utilize the new pagination hook, improving code consistency and reducing duplication. - Refactored pagination handling in each component to streamline state management and improve user experience during data navigation. - Enhanced search functionality to reset pagination state when new search parameters are applied, ensuring accurate data display.
This commit is contained in:
@@ -1,26 +1,24 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const MetaDataSchema = z.object({
|
||||
limit: z.number(),
|
||||
offset: z.number(),
|
||||
page: z.number(),
|
||||
pages: z.number(),
|
||||
total: z.number(),
|
||||
has_more: z.boolean().optional(),
|
||||
next_cursor: z.string().optional(),
|
||||
prev_cursor: z.string().optional(),
|
||||
});
|
||||
|
||||
export function createApiResponseSchema<T extends z.ZodTypeAny>(dataSchema: T) {
|
||||
return z.object({
|
||||
data: dataSchema,
|
||||
meta: z
|
||||
.object({
|
||||
limit: z.number(),
|
||||
offset: z.number(),
|
||||
page: z.number(),
|
||||
pages: z.number(),
|
||||
total: z.number(),
|
||||
})
|
||||
.optional(),
|
||||
meta: MetaDataSchema.optional(),
|
||||
message: z.string(),
|
||||
code: z.number().optional(),
|
||||
success: z.boolean(),
|
||||
});
|
||||
}
|
||||
|
||||
export type IMetaData = z.infer<typeof MetaDataSchema>;
|
||||
|
||||
Reference in New Issue
Block a user