diff --git a/src/shared/components/communities.tsx b/src/shared/components/communities.tsx index 236f777d..b3d288a8 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,