Skip to content
Snippets Groups Projects
Commit 02fd64d6 authored by Lukas's avatar Lukas
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 751832b7
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"; ...@@ -14,6 +14,7 @@ import { formatAndDelocalizeTime } from "@/utils/TimeUtils";
interface CommentPermlinkResultTableProps { interface CommentPermlinkResultTableProps {
data: Hive.Permlink[]; data: Hive.Permlink[];
accountName: string | undefined; accountName: string | undefined;
buildLink: (accountName: string, permlink: string) => {};
} }
const TABLE_CELLS = [ const TABLE_CELLS = [
...@@ -39,12 +40,15 @@ const buildTableHeader = () => { ...@@ -39,12 +40,15 @@ const buildTableHeader = () => {
const buildTableBody = ( const buildTableBody = (
data: Hive.Permlink[], data: Hive.Permlink[],
accountName: string | undefined accountName: string | undefined,
buildLink: (accountName: string, permlink: string) => {}
) => { ) => {
if (!data || !data.length || !accountName) return; if (!data || !data.length || !accountName) return;
return data.map( return data.map(
({ block, operation_id, permlink, timestamp, trx_id }: any) => { ({ block, operation_id, permlink, timestamp, trx_id }: any) => {
const linkToCommentsPage = buildLink(accountName, permlink);
return ( return (
<React.Fragment key={trx_id}> <React.Fragment key={trx_id}>
<TableRow className="border-b border-gray-700 hover:bg-inherit p-[10px]"> <TableRow className="border-b border-gray-700 hover:bg-inherit p-[10px]">
...@@ -55,9 +59,7 @@ const buildTableBody = ( ...@@ -55,9 +59,7 @@ const buildTableBody = (
{operation_id} {operation_id}
</TableCell> </TableCell>
<TableCell className="text-center text-link"> <TableCell className="text-center text-link">
<Link href={`/comments/@${accountName}?&permlink=${permlink}`}> <Link href={linkToCommentsPage}>{permlink}</Link>
{permlink}
</Link>
</TableCell> </TableCell>
<TableCell className="text-left text-text"> <TableCell className="text-left text-text">
{formatAndDelocalizeTime(timestamp)} {formatAndDelocalizeTime(timestamp)}
...@@ -73,6 +75,7 @@ const buildTableBody = ( ...@@ -73,6 +75,7 @@ const buildTableBody = (
}; };
const CommentPermlinkResultTable = ({ const CommentPermlinkResultTable = ({
buildLink,
data, data,
accountName, accountName,
}: CommentPermlinkResultTableProps) => { }: CommentPermlinkResultTableProps) => {
...@@ -84,7 +87,9 @@ const CommentPermlinkResultTable = ({ ...@@ -84,7 +87,9 @@ const CommentPermlinkResultTable = ({
<TableHeader> <TableHeader>
<TableRow>{buildTableHeader()}</TableRow> <TableRow>{buildTableHeader()}</TableRow>
</TableHeader> </TableHeader>
<TableBody>{buildTableBody(data, accountName)}</TableBody> <TableBody>
{buildTableBody(data, accountName, buildLink)}
</TableBody>
</Table> </Table>
</div> </div>
</div> </div>
......
...@@ -16,6 +16,7 @@ const CommentsPermlinkSearch = () => { ...@@ -16,6 +16,7 @@ const CommentsPermlinkSearch = () => {
setPermlinkSearchProps, setPermlinkSearchProps,
setCommentPaginationPage, setCommentPaginationPage,
setCommentType, setCommentType,
commentType,
setLastSearchKey, setLastSearchKey,
searchRanges, searchRanges,
} = useSearchesContext(); } = useSearchesContext();
...@@ -48,6 +49,7 @@ const CommentsPermlinkSearch = () => { ...@@ -48,6 +49,7 @@ const CommentsPermlinkSearch = () => {
lastTime: searchRanges.lastTimeUnitValue, lastTime: searchRanges.lastTimeUnitValue,
rangeSelectKey: searchRanges.rangeSelectKey, rangeSelectKey: searchRanges.rangeSelectKey,
timeUnit: searchRanges.timeUnitSelectKey, timeUnit: searchRanges.timeUnitSelectKey,
commentType,
}; };
startCommentPermlinkSearch( startCommentPermlinkSearch(
commentPermlinksSearchProps, commentPermlinksSearchProps,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment