Skip to content
Snippets Groups Projects
Commit 4b21e38a authored by Lukas's avatar Lukas
Browse files

Add pagination for comment search results and render results table based on view

parent 69a7edd7
Branches
No related tags found
1 merge request!524Lbudginas/#424 add new tab on account page
...@@ -3,6 +3,10 @@ import CommentPermlinkResultTable from "../CommentPermlinkResultTable"; ...@@ -3,6 +3,10 @@ import CommentPermlinkResultTable from "../CommentPermlinkResultTable";
import { useSearchesContext } from "@/contexts/SearchesContext"; import { useSearchesContext } from "@/contexts/SearchesContext";
import { getCommentPageLink } from "../utils/commentSearchHelpers"; import { getCommentPageLink } from "../utils/commentSearchHelpers";
import PostTypeSelector from "../PostTypeSelector"; import PostTypeSelector from "../PostTypeSelector";
import CustomPagination from "@/components/CustomPagination";
import { config } from "@/Config";
import { useRouter } from "next/router";
import AccountCommentPermlinkResultTable from "@/components/account/tabs/posts/AccountCommentPermlinkResultTable";
const CommentPermlinkSearchResults = () => { const CommentPermlinkSearchResults = () => {
const { const {
...@@ -11,7 +15,11 @@ const CommentPermlinkSearchResults = () => { ...@@ -11,7 +15,11 @@ const CommentPermlinkSearchResults = () => {
setCommentType, setCommentType,
setPermlinkSearchProps, setPermlinkSearchProps,
searchRanges, searchRanges,
permlinkPaginationPage,
setPermlinkPaginationPage,
} = useSearchesContext(); } = useSearchesContext();
const router = useRouter();
const isAccountPage = Boolean(router.query.accountName) || false;
const { permlinkSearchData } = usePermlinkSearch(permlinkSearchProps); const { permlinkSearchData } = usePermlinkSearch(permlinkSearchProps);
...@@ -42,10 +50,27 @@ const CommentPermlinkSearchResults = () => { ...@@ -42,10 +50,27 @@ const CommentPermlinkSearchResults = () => {
if (!permlinkSearchData) return; if (!permlinkSearchData) return;
const changePermlinkSearchPagination = (newPageNum: number) => {
const newSearchProps: any = {
...permlinkSearchProps,
pageNumber: newPageNum,
};
setPermlinkSearchProps(newSearchProps);
setPermlinkPaginationPage(newPageNum);
};
return ( return (
<> <>
{permlinkSearchData.total_permlinks ? ( {permlinkSearchData.total_permlinks ? (
<div> <div>
<div className="flex justify-center items-center text-text">
<CustomPagination
currentPage={permlinkPaginationPage}
totalCount={permlinkSearchData.total_permlinks}
pageSize={config.standardPaginationSize}
onPageChange={changePermlinkSearchPagination}
/>
</div>
<div className="flex justify-end my-4"> <div className="flex justify-end my-4">
<PostTypeSelector <PostTypeSelector
handleChange={handleChangeCommentType} handleChange={handleChangeCommentType}
...@@ -54,11 +79,18 @@ const CommentPermlinkSearchResults = () => { ...@@ -54,11 +79,18 @@ const CommentPermlinkSearchResults = () => {
</div> </div>
<div className="flex flex-wrap"> <div className="flex flex-wrap">
<CommentPermlinkResultTable {isAccountPage ? (
buildLink={buildLink} <AccountCommentPermlinkResultTable
data={permlinkSearchData.permlinks_result} data={permlinkSearchData.permlinks_result}
accountName={accountName} accountName={accountName}
/> />
) : (
<CommentPermlinkResultTable
buildLink={buildLink}
data={permlinkSearchData.permlinks_result}
accountName={accountName}
/>
)}
</div> </div>
</div> </div>
) : ( ) : (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment