GTBitsOfGood / canine-assistants

Educating the Dogs Who Change the World
https://dev--canine-assistants.netlify.app
MIT License
4 stars 0 forks source link

[FE/BE] Server-side pagination #189

Closed afazio1 closed 5 months ago

afazio1 commented 6 months ago

Description

Refactor pagination

Currently, our tables use client-side pagination, meaning we get all the table data on the first load of the page, but display only a few entries at a time. The problem with this is fetching all the dogs at once may overload the client. This becomes a noticeable problem as the number of dogs in the database increases.

Solution -> Move pagination to the server. This means only "x" dogs will be returned by an endpoint on any given request. Do this for the Dog Table and Logs tab.

You will notice that the Logs tab does not have frontend pagination. Add the pagination bar according to the Figma and hook it up to the backend.

These routes will have to be updated to support server-side pagination:

For the request to backend you will likely have to add two new properties:

{
    pageSize: 20,
    page: 1
}

Pagination UI

Currently, the pagination UI displays "Showing x of y Results", where y is the total number of dogs and x is the number of dogs being displayed. This information stays the same as the user moves through pages in the table because x is a total not an index.

Change the pagination UI to display "Showing x of y Results" where x is the index of the first entry and y is the total number of entries that match the filter criteria. We also want to display the current page number as well as the total number of pages.

You can likely calculate these totals on the backend and include them in the body of the response.

{
    data: {
        dogs: [
            {... dog1},
            {...dog2}
        ],
        page: 2
        pageSize: 20
        count: 100
    }
}

Acceptance Criteria

Other Notes