Skip to content

Commit e4a985d

Browse files
committed
Update pagination.tsx
Resolve Conflicts
1 parent 8112daa commit e4a985d

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

src/app/(public)/repos/_components/pagination.tsx

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1+
'use client';
2+
13
import { Button } from '@/app/(public)/_components/button';
2-
<<<<<<< Updated upstream
3-
import { ArrowLeft, ArrowRight } from 'lucide-react';
4-
import Link from 'next/link';
5-
import type { SearchParams } from '@/types';
6-
=======
74
import { ArrowLeft, ArrowRight, Loader2 } from 'lucide-react';
85
import { useTransition } from 'react';
96
import { useQueryState } from 'nuqs';
10-
>>>>>>> Stashed changes
117

128
const MAX_PER_PAGE = 21;
139
interface PaginationProps {
@@ -19,8 +15,6 @@ export function Pagination({
1915
page,
2016
totalCount
2117
}: PaginationProps) {
22-
<<<<<<< Updated upstream
23-
=======
2418
const [, setPageParam] = useQueryState('p', {
2519
defaultValue: '1',
2620
parse: (value: string) => value,
@@ -35,25 +29,46 @@ export function Pagination({
3529
});
3630
}
3731

38-
>>>>>>> Stashed changes
3932
return (
4033
<div className="flex flex-col items-center gap-4 my-6 justify-evenly sm:gap-0 sm:flex-row">
4134
{page > 1 && (
42-
<Link href={{ query: { ...searchParams, p: page - 1 } }}>
43-
<Button className="btn-wide hover:bg-primary-btn-hover-gradient hover:text-hacktoberfest-dark-green">
44-
<ArrowLeft />
45-
<span className="ml-2">Previous Page</span>
46-
</Button>
47-
</Link>
35+
<Button
36+
onClick={() => changePage(-1)}
37+
disabled={isPending}
38+
className="btn-wide hover:bg-primary-btn-hover-gradient hover:text-hacktoberfest-dark-green disabled:opacity-50 disabled:cursor-not-allowed"
39+
>
40+
{isPending ? (
41+
<>
42+
<Loader2 className="animate-spin" />
43+
<span className="ml-2">Loading...</span>
44+
</>
45+
) : (
46+
<>
47+
<ArrowLeft />
48+
<span className="ml-2">Previous Page</span>
49+
</>
50+
)}
51+
</Button>
4852
)}
4953
{totalCount >= MAX_PER_PAGE &&
5054
page < Math.ceil(totalCount / MAX_PER_PAGE) && (
51-
<Link href={{ query: { ...searchParams, p: page + 1 } }}>
52-
<Button className="btn-wide hover:bg-primary-btn-hover-gradient hover:text-hacktoberfest-dark-green">
53-
<span className="mr-2">Next Page</span>
54-
<ArrowRight />
55-
</Button>
56-
</Link>
55+
<Button
56+
onClick={() => changePage(1)}
57+
disabled={isPending}
58+
className="btn-wide hover:bg-primary-btn-hover-gradient hover:text-hacktoberfest-dark-green disabled:opacity-50 disabled:cursor-not-allowed"
59+
>
60+
{isPending ? (
61+
<>
62+
<span className="mr-2">Loading...</span>
63+
<Loader2 className="animate-spin" />
64+
</>
65+
) : (
66+
<>
67+
<span className="mr-2">Next Page</span>
68+
<ArrowRight />
69+
</>
70+
)}
71+
</Button>
5772
)}
5873
</div>
5974
);

0 commit comments

Comments
 (0)