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

Add permlink filter by comment type

parent 829f02b1
Branches
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 {
} from "../ui/accordion";
import usePermlinkSearch from "@/hooks/api/common/usePermlinkSearch";
import CommentPermlinkResultTable from "./searches/CommentPermlinkResultTable";
import {
Select,
SelectTrigger,
SelectValue,
SelectGroup,
SelectContent,
SelectItem,
} from "../ui/select";
import { capitalizeFirst } from "@/utils/StringUtils";
interface SearchesSectionProps {}
type CommentType = "all" | "post" | "comment";
const COMMENT_TYPES = ["all", "post", "comment"];
const SearchesSection: React.FC<SearchesSectionProps> = ({}) => {
const [accordionValue, setAccordionValue] = useState<string>("block");
const [previousCommentSearchProps, setPreviousCommentSearchProps] = useState<
......@@ -75,6 +87,9 @@ const SearchesSection: React.FC<SearchesSectionProps> = ({}) => {
const [accountOperationsSearchProps, setAccountOperationsSearchProps] =
useState<Explorer.AccountSearchOperationsProps | undefined>(undefined);
const [isAllSearchLoading, setIsAllSearchLoading] = useState<boolean>(false);
const [commentType, setCommentType] = useState<CommentType | undefined>(
undefined
);
const searchesRef = useRef<HTMLDivElement | null>(null);
......@@ -168,6 +183,7 @@ const SearchesSection: React.FC<SearchesSectionProps> = ({}) => {
setIsAllSearchLoading(true);
setPermlinkSearchProps(props);
setCommentPaginationPage(1);
setCommentType(undefined);
setLastSearchKey("comment-permlink");
};
......@@ -347,6 +363,16 @@ const SearchesSection: React.FC<SearchesSectionProps> = ({}) => {
return `/block/${blockNumber}${getPageUrlParams(urlParams)}`;
};
const handleChangeCommentType = (e: CommentType) => {
setCommentType(e);
setPermlinkSearchProps((prev: any) => {
return {
...prev,
commentType: e,
};
});
};
return (
<>
<Card
......@@ -456,11 +482,27 @@ const SearchesSection: React.FC<SearchesSectionProps> = ({}) => {
)}
{permlinkSearchData && lastSearchKey === "comment-permlink" && (
<div>
<div
className="text-center my-5"
data-testid="result-section-header"
>
Results:
<div className="flex justify-end my-4">
<Select
onValueChange={handleChangeCommentType}
value={commentType}
>
<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 className="flex flex-wrap">
{permlinkSearchData.total_permlinks > 0 ? (
......
......@@ -54,7 +54,7 @@ const buildTableBody = (
<TableCell className="text-left text-text">
{operation_id}
</TableCell>
<TableCell className="text-right text-link">
<TableCell className="text-center text-link">
<Link href={`/comments/@${accountName}?&permlink=${permlink}`}>
{permlink}
</Link>
......
......@@ -335,6 +335,7 @@ class FetchingService {
): Promise<Hive.CommentPermlinksResponse> {
const requestParams: Hive.GetCommentPermlinksParams = {
accountName: permlinkSearchProps.accountName,
"comment-type": permlinkSearchProps.commentType,
page: 1,
"page-size": 100,
"from-block":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment