Skip to content
Snippets Groups Projects
Commit 2431a63e authored by Lukas's avatar Lukas Committed by mcfarhat
Browse files

Update comment permlink search result to navigate to comment page with...

Update comment permlink search result to navigate to comment page with selected params when permlink is clicked
parent 7da5746c
No related branches found
No related tags found
1 merge request!499#392_part2_simplify_URL_route_build
......@@ -14,6 +14,7 @@ import { formatAndDelocalizeTime } from "@/utils/TimeUtils";
interface CommentPermlinkResultTableProps {
data: Hive.Permlink[];
accountName: string | undefined;
buildLink: (accountName: string, permlink: string) => {};
}
const TABLE_CELLS = [
......@@ -39,12 +40,15 @@ const buildTableHeader = () => {
const buildTableBody = (
data: Hive.Permlink[],
accountName: string | undefined
accountName: string | undefined,
buildLink: (accountName: string, permlink: string) => {}
) => {
if (!data || !data.length || !accountName) return;
return data.map(
({ block, operation_id, permlink, timestamp, trx_id }: any) => {
const linkToCommentsPage = buildLink(accountName, permlink);
return (
<React.Fragment key={trx_id}>
<TableRow className="border-b border-gray-700 hover:bg-inherit p-[10px]">
......@@ -55,9 +59,7 @@ const buildTableBody = (
{operation_id}
</TableCell>
<TableCell className="text-center text-link">
<Link href={`/comments/@${accountName}?&permlink=${permlink}`}>
{permlink}
</Link>
<Link href={linkToCommentsPage}>{permlink}</Link>
</TableCell>
<TableCell className="text-left text-text">
{formatAndDelocalizeTime(timestamp)}
......@@ -73,6 +75,7 @@ const buildTableBody = (
};
const CommentPermlinkResultTable = ({
buildLink,
data,
accountName,
}: CommentPermlinkResultTableProps) => {
......@@ -84,7 +87,9 @@ const CommentPermlinkResultTable = ({
<TableHeader>
<TableRow>{buildTableHeader()}</TableRow>
</TableHeader>
<TableBody>{buildTableBody(data, accountName)}</TableBody>
<TableBody>
{buildTableBody(data, accountName, buildLink)}
</TableBody>
</Table>
</div>
</div>
......
......@@ -16,6 +16,7 @@ const CommentsPermlinkSearch = () => {
setPermlinkSearchProps,
setCommentPaginationPage,
setCommentType,
commentType,
setLastSearchKey,
searchRanges,
} = useSearchesContext();
......@@ -48,6 +49,7 @@ const CommentsPermlinkSearch = () => {
lastTime: searchRanges.lastTimeUnitValue,
rangeSelectKey: searchRanges.rangeSelectKey,
timeUnit: searchRanges.timeUnitSelectKey,
commentType,
};
startCommentPermlinkSearch(
commentPermlinksSearchProps,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment