1+ 'use client' ;
2+
13import { 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- = === ===
74import { ArrowLeft , ArrowRight , Loader2 } from 'lucide-react' ;
85import { useTransition } from 'react' ;
96import { useQueryState } from 'nuqs' ;
10- > >>> >>> Stashed changes
117
128const MAX_PER_PAGE = 21 ;
139interface 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