Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Pagination #3

Merged
merged 4 commits into from
Dec 3, 2024
Merged

feat: Pagination #3

merged 4 commits into from
Dec 3, 2024

Conversation

tunny17
Copy link
Collaborator

@tunny17 tunny17 commented Dec 3, 2024

No description provided.

@tunny17 tunny17 requested a review from rotimi-best December 3, 2024 08:54
Copy link
Contributor

@rotimi-best rotimi-best left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please take a look at my comments on Discord and let me know if you have questions

Comment on lines 141 to 157
$: {
if (typeof currentPage === 'number') {
const url = new URL(window.location.href);
url.searchParams.set('page', currentPage.toString());
history.replaceState(null, '', url.toString());
}
}

console.log('apiMetadata', apiMetadata);
onMount(() => {
const params = new URLSearchParams(window.location.search);
const pageParam = parseInt(params.get('page'), 10);
currentPage =
!isNaN(pageParam) && pageParam > 0
? pageParam
: apiMetadata?.pagination?.currentPage || 1;
currentOrder = apiMetadata?.sort?.order || 'desc';
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is complex to manage and understand. However for now, I will let this get merged in

@rotimi-best rotimi-best merged commit 11eb4a6 into main Dec 3, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants