developer-content icon indicating copy to clipboard operation
developer-content copied to clipboard

feat: Add pagination and sorting support to getRecordsForGroup utility

Open SashaMalysehko opened this issue 1 year ago • 0 comments

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 page and pageSize parameters
  • Implemented sorting functionality with sortField and sortDirection options
  • 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

SashaMalysehko avatar Jan 11 '25 12:01 SashaMalysehko