nextjs-postgres-nextauth-tailwindcss-template icon indicating copy to clipboard operation
nextjs-postgres-nextauth-tailwindcss-template copied to clipboard

Pagination issues

Open T04435 opened this issue 1 year ago • 1 comments

few things:

  • Prev (shouldn't router.back())
  • Prev never disabled
  • if active search ?q=foo the message Showing x-y of z breaks x is negative

Happy to update this to shadcn/ui > Pagination

T04435 avatar Jul 18 '24 14:07 T04435

Hi! Not only that, if you search for products with ?q=a, you will get 10 items on the page (all containing the letter 'a'). The reason for this is incorrect logic in the /lib/db.ts file (and some other places). The offset is set incorrectly and currently reflects the offset for future queries instead of the current one. When performing a search with no query, the offset is set to the old offset + 5, but only if the previous offset is not null and greater than 5.

I believe I have solved all the issues You have listed. If possible, could I create a PR for this? 😃

The only question I have is what should be done when searching for a product with an active search? In my fix, I show all items found and hide the bar that displays the number of items and the buttons for switching between pages.

jakub-pazio avatar Jul 30 '24 22:07 jakub-pazio