learnhubmk / app

The frontend app for LearnHub.mk
https://learnhub.mk
MIT License
6 stars 0 forks source link

[FE] Implement Page-based Pagination #451

Closed petark7 closed 2 days ago

petark7 commented 5 days ago

This PR introduces a reusable page-based pagination component for tables (such as blogs, tags, etc.). It relies on the backend's pagination implementation, which returns a meta object, as shown below.

Instead of using the links array, we calculate the number of pages using current_page and last_page. This approach offers a simpler implementation and greater flexibility for customization.

Additionally, the tags query has been updated to include all relevant interfaces, with added support for passing a "page" query parameter in the request.

p.s Needs content-manager permissions (bearer token set to .env) to test.

Example meta object returned from backend:

"meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 2,
        "links": [
            {
                "url": null,
                "label": "« Претходна",
                "active": false
            },
            {
                "url": "https://staging-api.learnhub.mk/content/blog-post-tags?page=1",
                "label": "1",
                "active": true
            },
            {
                "url": "https://staging-api.learnhub.mk/content/blog-post-tags?page=2",
                "label": "2",
                "active": false
            },
            {
                "url": "https://staging-api.learnhub.mk/content/blog-post-tags?page=2",
                "label": "Следна »",
                "active": false
            }
        ],
        "path": "https://staging-api.learnhub.mk/content/blog-post-tags",
        "per_page": 20,
        "to": 20,
        "total": 24
    }
vercel[bot] commented 5 days ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 19, 2024 7:46am