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