Skip to content

Commit

Permalink
CM-333: filter individuals by group id (#27)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan <j.dolkowski@soldevelo.com>
  • Loading branch information
jdolkowski and Jan authored Oct 3, 2023
1 parent 9d068ab commit 5e020bb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
11 changes: 9 additions & 2 deletions src/components/GroupIndividualFilter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import { injectIntl } from 'react-intl';
import { TextInput, PublishedComponent, formatMessage } from '@openimis/fe-core';
import { Grid } from '@material-ui/core';
Expand All @@ -9,7 +9,7 @@ import { defaultFilterStyles } from '../util/styles';
import GroupIndividualRolePicker from '../pickers/GroupIndividualRolePicker';

function GroupIndividualFilter({
intl, classes, filters, onChangeFilters,
intl, classes, filters, onChangeFilters, groupId,
}) {
const debouncedOnChangeFilters = _debounce(onChangeFilters, DEFAULT_DEBOUNCE_TIME);

Expand Down Expand Up @@ -37,6 +37,13 @@ function GroupIndividualFilter({
}
};

const handleGroupId = onChangeStringFilter('group_Id');
useEffect(() => {
if (filters?.group_Id?.value !== groupId) {
handleGroupId(groupId);
}
}, [groupId]);

return (
<Grid container className={classes.form}>
<Grid item xs={2} className={classes.item}>
Expand Down
41 changes: 24 additions & 17 deletions src/components/GroupIndividualSearcher.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
import React, { useState, useEffect, useRef } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { injectIntl } from 'react-intl';
import {
withModulesManager,
clearConfirm,
coreConfirm,
downloadExport,
formatDateFromISO,
formatMessage,
formatMessageWithValues,
Searcher,
formatDateFromISO,
coreConfirm,
clearConfirm,
historyPush,
journalize,
Searcher,
withHistory,
historyPush,
downloadExport,
withModulesManager,
} from '@openimis/fe-core';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import {
IconButton, Tooltip, Button,
Dialog,
DialogActions,
DialogTitle,
Button, Dialog, DialogActions, DialogTitle, IconButton, Tooltip,
} from '@material-ui/core';
import EditIcon from '@material-ui/icons/Edit';
import DeleteIcon from '@material-ui/icons/Delete';
import {
fetchGroupIndividuals,
deleteGroupIndividual,
clearGroupIndividualExport,
deleteGroupIndividual,
downloadGroupIndividuals,
fetchGroupIndividuals,
updateGroupIndividual,
} from '../actions';
import {
DEFAULT_PAGE_SIZE,
ROWS_PER_PAGE_OPTIONS,
EMPTY_STRING,
RIGHT_GROUP_INDIVIDUAL_UPDATE,
RIGHT_GROUP_INDIVIDUAL_DELETE,
RIGHT_GROUP_INDIVIDUAL_UPDATE,
ROWS_PER_PAGE_OPTIONS,
} from '../constants';
import GroupIndividualFilter from './GroupIndividualFilter';
import GroupIndividualRolePicker from '../pickers/GroupIndividualRolePicker';
Expand Down Expand Up @@ -255,11 +252,21 @@ function GroupIndividualSearcher({
return filters;
};

const groupBeneficiaryFilter = (props) => (
<GroupIndividualFilter
intl={props.intl}
classes={props.classes}
filters={props.filters}
onChangeFilters={props.onChangeFilters}
groupId={groupId}
/>
);

return (
<div>
<Searcher
module="individual"
FilterPane={GroupIndividualFilter}
FilterPane={groupBeneficiaryFilter}
fetch={fetch}
items={groupIndividuals}
itemsPageInfo={groupIndividualsPageInfo}
Expand Down

0 comments on commit 5e020bb

Please sign in to comment.