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

Add permlink filter by comment type

parent 829f02b1
No related branches found
No related tags found
2 merge requests!481bring recent develop changes to mater to match the backend,!467Lbudginas/#364 update search responses
Pipeline #109102 canceled
...@@ -44,9 +44,21 @@ import { ...@@ -44,9 +44,21 @@ import {
} from "../ui/accordion"; } from "../ui/accordion";
import usePermlinkSearch from "@/hooks/api/common/usePermlinkSearch"; import usePermlinkSearch from "@/hooks/api/common/usePermlinkSearch";
import CommentPermlinkResultTable from "./searches/CommentPermlinkResultTable"; import CommentPermlinkResultTable from "./searches/CommentPermlinkResultTable";
import {
Select,
SelectTrigger,
SelectValue,
SelectGroup,
SelectContent,
SelectItem,
} from "../ui/select";
import { capitalizeFirst } from "@/utils/StringUtils";
interface SearchesSectionProps {} interface SearchesSectionProps {}
type CommentType = "all" | "post" | "comment";
const COMMENT_TYPES = ["all", "post", "comment"];
const SearchesSection: React.FC<SearchesSectionProps> = ({}) => { const SearchesSection: React.FC<SearchesSectionProps> = ({}) => {
const [accordionValue, setAccordionValue] = useState<string>("block"); const [accordionValue, setAccordionValue] = useState<string>("block");
const [previousCommentSearchProps, setPreviousCommentSearchProps] = useState< const [previousCommentSearchProps, setPreviousCommentSearchProps] = useState<
...@@ -75,6 +87,9 @@ const SearchesSection: React.FC<SearchesSectionProps> = ({}) => { ...@@ -75,6 +87,9 @@ const SearchesSection: React.FC<SearchesSectionProps> = ({}) => {
const [accountOperationsSearchProps, setAccountOperationsSearchProps] = const [accountOperationsSearchProps, setAccountOperationsSearchProps] =
useState<Explorer.AccountSearchOperationsProps | undefined>(undefined); useState<Explorer.AccountSearchOperationsProps | undefined>(undefined);
const [isAllSearchLoading, setIsAllSearchLoading] = useState<boolean>(false); const [isAllSearchLoading, setIsAllSearchLoading] = useState<boolean>(false);
const [commentType, setCommentType] = useState<CommentType | undefined>(
undefined
);
const searchesRef = useRef<HTMLDivElement | null>(null); const searchesRef = useRef<HTMLDivElement | null>(null);
...@@ -168,6 +183,7 @@ const SearchesSection: React.FC<SearchesSectionProps> = ({}) => { ...@@ -168,6 +183,7 @@ const SearchesSection: React.FC<SearchesSectionProps> = ({}) => {
setIsAllSearchLoading(true); setIsAllSearchLoading(true);
setPermlinkSearchProps(props); setPermlinkSearchProps(props);
setCommentPaginationPage(1); setCommentPaginationPage(1);
setCommentType(undefined);
setLastSearchKey("comment-permlink"); setLastSearchKey("comment-permlink");
}; };
...@@ -347,6 +363,16 @@ const SearchesSection: React.FC<SearchesSectionProps> = ({}) => { ...@@ -347,6 +363,16 @@ const SearchesSection: React.FC<SearchesSectionProps> = ({}) => {
return `/block/${blockNumber}${getPageUrlParams(urlParams)}`; return `/block/${blockNumber}${getPageUrlParams(urlParams)}`;
}; };
const handleChangeCommentType = (e: CommentType) => {
setCommentType(e);
setPermlinkSearchProps((prev: any) => {
return {
...prev,
commentType: e,
};
});
};
return ( return (
<> <>
<Card <Card
...@@ -456,11 +482,27 @@ const SearchesSection: React.FC<SearchesSectionProps> = ({}) => { ...@@ -456,11 +482,27 @@ const SearchesSection: React.FC<SearchesSectionProps> = ({}) => {
)} )}
{permlinkSearchData && lastSearchKey === "comment-permlink" && ( {permlinkSearchData && lastSearchKey === "comment-permlink" && (
<div> <div>
<div <div className="flex justify-end my-4">
className="text-center my-5" <Select
data-testid="result-section-header" onValueChange={handleChangeCommentType}
> value={commentType}
Results: >
<SelectTrigger className="w-[180px] border-0">
<SelectValue placeholder="Comment Type" />
</SelectTrigger>
<SelectContent className="border-0">
<SelectGroup>
{COMMENT_TYPES.map((type, index) => (
<SelectItem
key={index}
value={`${type}`}
>
{capitalizeFirst(type)}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
</div> </div>
<div className="flex flex-wrap"> <div className="flex flex-wrap">
{permlinkSearchData.total_permlinks > 0 ? ( {permlinkSearchData.total_permlinks > 0 ? (
......
...@@ -54,7 +54,7 @@ const buildTableBody = ( ...@@ -54,7 +54,7 @@ const buildTableBody = (
<TableCell className="text-left text-text"> <TableCell className="text-left text-text">
{operation_id} {operation_id}
</TableCell> </TableCell>
<TableCell className="text-right text-link"> <TableCell className="text-center text-link">
<Link href={`/comments/@${accountName}?&permlink=${permlink}`}> <Link href={`/comments/@${accountName}?&permlink=${permlink}`}>
{permlink} {permlink}
</Link> </Link>
......
...@@ -335,6 +335,7 @@ class FetchingService { ...@@ -335,6 +335,7 @@ class FetchingService {
): Promise<Hive.CommentPermlinksResponse> { ): Promise<Hive.CommentPermlinksResponse> {
const requestParams: Hive.GetCommentPermlinksParams = { const requestParams: Hive.GetCommentPermlinksParams = {
accountName: permlinkSearchProps.accountName, accountName: permlinkSearchProps.accountName,
"comment-type": permlinkSearchProps.commentType,
page: 1, page: 1,
"page-size": 100, "page-size": 100,
"from-block": "from-block":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment