From 94e36ad7573b4f186716abfaa264d2b22ce8dd52 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 23 Jan 2021 18:07:02 -0500 Subject: [PATCH] Add search field to communities page. Fixes #118 --- src/shared/components/communities.tsx | 45 ++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/shared/components/communities.tsx b/src/shared/components/communities.tsx index 236f777..b3d288a 100644 --- a/src/shared/components/communities.tsx +++ b/src/shared/components/communities.tsx @@ -35,6 +35,7 @@ interface CommunitiesState { page: number; loading: boolean; site_view: SiteView; + searchText: string; } interface CommunitiesProps { @@ -49,6 +50,7 @@ export class Communities extends Component { loading: true, page: getPageFromProps(this.props), site_view: this.isoData.site_res.site_view, + searchText: '', }; constructor(props: any, context: any) { @@ -108,7 +110,15 @@ export class Communities extends Component { ) : (
-
{i18n.t('list_of_communities')}
+
+
+

{i18n.t('list_of_communities')}

+
+
+
{this.searchForm()}
+
+
+
@@ -174,6 +184,28 @@ export class Communities extends Component { ); } + searchForm() { + return ( +
+ + + + ); + } + paginator() { return (
@@ -229,6 +261,17 @@ export class Communities extends Component { WebSocketService.Instance.send(wsClient.followCommunity(form)); } + handleSearchChange(i: Communities, event: any) { + i.setState({ searchText: event.target.value }); + } + + handleSearchSubmit(i: Communities) { + const searchParamEncoded = encodeURIComponent(i.state.searchText); + i.context.router.history.push( + `/search/q/${searchParamEncoded}/type/Communities/sort/TopAll/page/1` + ); + } + refetch() { let listCommunitiesForm: ListCommunities = { sort: SortType.TopAll, -- 2.44.1