mirror of
https://github.com/koreanbots/core.git
synced 2025-12-15 14:10:22 +00:00
fix: query string invalid
fix: https://github.com/koreanbots/v2-testing/issues/92
This commit is contained in:
parent
540d596c25
commit
3be25d6fe8
@ -1,5 +1,5 @@
|
||||
import Link from 'next/link'
|
||||
const Paginator = ({ currentPage, totalPage, pathname }: PaginatorProps): JSX.Element => {
|
||||
const Paginator = ({ currentPage, totalPage, pathname, searchParams }: PaginatorProps): JSX.Element => {
|
||||
let pages = []
|
||||
if (currentPage < 4)
|
||||
pages = [
|
||||
@ -29,7 +29,7 @@ const Paginator = ({ currentPage, totalPage, pathname }: PaginatorProps): JSX.El
|
||||
return (
|
||||
<div className='flex flex-col items-center justify-center py-4 text-center'>
|
||||
<div className='flex'>
|
||||
<Link href={{ pathname, hash: 'list', query: { page: currentPage - 1 } }}>
|
||||
<Link href={{ pathname, hash: 'list', query: { ...searchParams, page: currentPage - 1 } }}>
|
||||
<a
|
||||
className={`${
|
||||
currentPage === 1 ? 'invisible' : ''
|
||||
@ -39,7 +39,7 @@ const Paginator = ({ currentPage, totalPage, pathname }: PaginatorProps): JSX.El
|
||||
</a>
|
||||
</Link>
|
||||
{pages.map((el, i) => (
|
||||
<Link key={i} href={{ pathname, hash: 'list', query: { page: el } }}>
|
||||
<Link key={i} href={{ pathname, hash: 'list', query: { ...searchParams, page: el } }}>
|
||||
<a
|
||||
className={`w-12 flex justify-center items-center cursor-pointer leading-5 transition duration-150 ease-in ${
|
||||
i === 0 && i === pages.length - 1
|
||||
@ -59,7 +59,7 @@ const Paginator = ({ currentPage, totalPage, pathname }: PaginatorProps): JSX.El
|
||||
</a>
|
||||
</Link>
|
||||
))}
|
||||
<Link href={{ pathname, hash: 'list', query: { page: currentPage + 1 } }}>
|
||||
<Link href={{ pathname, hash: 'list', query: { ...searchParams, page: currentPage + 1 } }}>
|
||||
<a
|
||||
className={`${
|
||||
currentPage === totalPage ? 'invisible' : ''
|
||||
@ -77,6 +77,7 @@ interface PaginatorProps {
|
||||
pathname: string
|
||||
currentPage: number
|
||||
totalPage: number
|
||||
searchParams: Record<string, string|string[]>
|
||||
}
|
||||
|
||||
export default Paginator
|
||||
|
||||
@ -31,7 +31,7 @@ const Search:NextPage<SearchProps> = ({ data, query }) => {
|
||||
data.data.map(bot => <BotCard key={bot.id} bot={bot} /> )
|
||||
}
|
||||
</ResponsiveGrid>
|
||||
<Paginator totalPage={data.totalPage} currentPage={data.currentPage} pathname={`/search?q=${query.q}`} />
|
||||
<Paginator totalPage={data.totalPage} currentPage={data.currentPage} pathname='/search' searchParams={query} />
|
||||
</>
|
||||
}
|
||||
<Advertisement />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user