developer-content
developer-content copied to clipboard
feat: Add pagination and sorting support to getRecordsForGroup utility
Problem
The getRecordsForGroup function in src/utils/records.ts lacks pagination and sorting capabilities, as indicated by two TODO comments:
- "todo: add pagination support here"
- "todo: add the ability to auto sort based on a given field"
This makes it difficult to handle large sets of records efficiently and organize them in a meaningful way.
Summary of Changes
- Added pagination support with
pageandpageSizeparameters - Implemented sorting functionality with
sortFieldandsortDirectionoptions - Added pagination metadata including:
- Total records count
- Total pages
- Current page
- Next/previous page indicators
- Added TypeScript interfaces for better type safety:
-
PaginationMetadata -
PaginatedResponse
-
- Maintained backward compatibility with existing code
- Added proper type annotations to fix TypeScript linting issues