diff --git a/components/home/SearchesSection.tsx b/components/home/SearchesSection.tsx index 3fdd1e2ac10915289612d05ce37e11daaa78b16d..120cefc333577d40045605fd4b6717139c538c83 100644 --- a/components/home/SearchesSection.tsx +++ b/components/home/SearchesSection.tsx @@ -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 ? ( diff --git a/components/home/searches/CommentPermlinkResultTable.tsx b/components/home/searches/CommentPermlinkResultTable.tsx index d093abf511635da057a25df43928353c6ff18692..a2c8bb9c1cbdd4d29d818be3ec336070cc1d773f 100644 --- a/components/home/searches/CommentPermlinkResultTable.tsx +++ b/components/home/searches/CommentPermlinkResultTable.tsx @@ -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> diff --git a/services/FetchingService.ts b/services/FetchingService.ts index bb5cc20143463b8a52317b7abe2fea77c800ac70..8d4997bff16347628617d8b86317b84b7d55e4b6 100644 --- a/services/FetchingService.ts +++ b/services/FetchingService.ts @@ -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":