Skip to content

Commit

Permalink
fix: page numbers are now correct
Browse files Browse the repository at this point in the history
  • Loading branch information
djpiper28 committed Nov 26, 2023
1 parent 68c75c9 commit cf23568
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions frontend/src/app/q/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,29 @@ export default async function SearchResultPage({
const pages = Math.ceil(results / page_size);

return (
<div className="flex flex-col gap-5 pb-5 pt-5">
<div className="flex flex-col gap-5 pb-5 pt-5 justify-between">
<div className="w-full mx-auto grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4">
{data.cards.map((item: any) => (
<Card data={item} key={item} />
))}
</div>
<p className="text-center">
{results} Results | Page {page} / {pages}
</p>
<div className="flex flex-row gap-3 w-full overflow-x-auto py-5">
{Array(pages)
.fill(0)
.slice(Math.max(0, page - 5), page + 1 + 50)
.map((_, i) => (
<PageChanger
base_url={"/q/?query=" + searchParams.query}
page={i + 1}
key={i}
currentPage={(i + 1).toString() == searchParams.page}
/>
))}
<div className="flex flex-col">
<p className="text-center">
{results} Results | Page {page + 1} / {pages}
</p>
<div className="flex flex-row gap-3 w-full overflow-x-auto py-5">
{Array(pages)
.fill(0)
.slice(Math.max(0, page - 5), page + 1 + 50)
.map((_, i) => (
<PageChanger
base_url={"/q/?query=" + searchParams.query}
page={i + 1}
key={i}
currentPage={(i + 1).toString() == searchParams.page}
/>
))}
</div>
</div>
</div>
);
Expand Down

0 comments on commit cf23568

Please sign in to comment.