added filter for groups

This commit is contained in:
Florian Scholdei
2019-04-10 17:24:35 +02:00
parent 77b1bb53e8
commit 99e78da67b
2 changed files with 13 additions and 5 deletions

View File

@@ -39,7 +39,7 @@ type Props = {
history: History,
// dispatch functions
fetchGroupsByPage: (link: string, page: number) => void,
fetchGroupsByPage: (link: string, page: number, filter?: string) => void,
fetchGroupsByLink: (link: string) => void
};
@@ -74,6 +74,9 @@ class Groups extends React.Component<Props> {
subtitle={t("groups.subtitle")}
loading={loading || !groups}
error={error}
filter={filter => {
this.props.fetchGroupsByPage(this.props.groupLink, this.props.page, filter);
}}
>
<GroupTable groups={groups} />
{this.renderPaginator()}
@@ -152,8 +155,8 @@ const mapStateToProps = (state, ownProps) => {
const mapDispatchToProps = dispatch => {
return {
fetchGroupsByPage: (link: string, page: number) => {
dispatch(fetchGroupsByPage(link, page));
fetchGroupsByPage: (link: string, page: number, filter?: string) => {
dispatch(fetchGroupsByPage(link, page, filter));
},
fetchGroupsByLink: (link: string) => {
dispatch(fetchGroupsByLink(link));

View File

@@ -40,9 +40,14 @@ export function fetchGroups(link: string) {
return fetchGroupsByLink(link);
}
export function fetchGroupsByPage(link: string, page: number) {
export function fetchGroupsByPage(link: string, page: number, filter?: string) {
// backend start counting by 0
return fetchGroupsByLink(link + "?page=" + (page - 1));
if (filter) {
return fetchGroupsByLink(
`${link}?page=${page - 1}&q=${decodeURIComponent(filter)}`
);
}
return fetchGroupsByLink(`${link}?page=${page - 1}`);
}
export function fetchGroupsByLink(link: string) {