Skip to content

Add Pagination component for price benchmark #2840

@asvinb

Description

@asvinb

User story

Part of #2824

As a merchant, I want to be able to paginate through the price benchmark table data.

Image

Figma link

https://www.figma.com/design/fqR0EHi63lWahRcVTKCcba/Google-Listings---Ads-v2.x?node-id=10866-63096&t=tLMAmPRxgwNdCljW-4

Acceptance criteria

  • The Pagination component should allow users to paginate through a set of data.
  • The table should show 10 products per page.

Implementation brief

  • Custom pagination logic should be added to work with Google's token based pagination compared to the default offset based pagination of DataViews
    • Create js/src/pages/price-benchmark/pagination/index.js which houses the Pagination component and it should render the same markup as the DataViews pagination buttons.
      • It accepts the following props:
        • hasNextPage: boolean
        • hasPrevPage: boolean
        • onPreviousPageClick: callback function
        • onNextPageClick: callback function
    • Within PriceBenchmarkSuggestionsTable and PriceBenchmarkAdjustmentsTable,
      • Add the following state variables:
        • nextToken: (string) to store the next token
        • previousTokens: array to store all the previous tokens
        • currentPage: integer to know which token index is currently being used
      • Render the Pagination component
        • onPreviousPageClick callback should fetch data based on the previous token (determined from currentPage)
        • onNextPageClick callback should add the current token to the list of previous tokens and then fetch data with the new token.
          • The selector returning the data should also return a next_page_token property which will be used to determine if there are additional results, i.e hasNextPage.
      • totalItems and totalPages should be set to 0 for the paginationInfo prop of DataViews to prevent the default DataViews pagination from being rendered. The filterSortAndPaginate function cannot be used.
      • Consider adding a placeholder/animation when new data is being fetched.

Out of bounds/rabbit holes

Test coverage

  • Appropriate E2E tests should be added for the following features:
    • data pagination, i.e correct set of data is loading when clicking the "Previous" and "Next" buttons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: on holdThe issue is currently not prioritized.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions