Skip to content

Commit

Permalink
CM-819: added adjustments for group beneficiaires: advanced filters, …
Browse files Browse the repository at this point in the history
…download with custom filters
  • Loading branch information
sniedzielski committed May 24, 2024
1 parent df96bf2 commit 618633c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/components/BenefitPlanFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import _debounce from 'lodash/debounce';
import { CONTAINS_LOOKUP, DEFAULT_DEBOUNCE_TIME, EMPTY_STRING } from '../constants';
import { defaultFilterStyles } from '../util/styles';
import BeneficiaryStatusPicker from '../pickers/BeneficiaryStatusPicker';
import BenefitPlanTypePicker from '../pickers/BenefitPlanTypePicker';

function BenefitPlanFilter({
intl, classes, filters, onChangeFilters, showStatuses,
Expand Down Expand Up @@ -66,6 +67,21 @@ function BenefitPlanFilter({
onChange={onChangeStringFilter('name', CONTAINS_LOOKUP)}
/>
</Grid>
<Grid item xs={3} className={classes.item}>
<BenefitPlanTypePicker
module="socialProtection"
label="beneficiary.benefitPlanTypePicker"
value={filterValue('type')}
onChange={(v) => onChangeFilters([
{
id: 'type',
value: v,
filter: `type: ${v}`,
},
])}
withNull={false}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<PublishedComponent
pubRef="core.DatePicker"
Expand Down
21 changes: 21 additions & 0 deletions src/components/BenefitPlanGroupBeneficiariesSearcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ import {
RIGHT_GROUP_SEARCH,
RIGHT_BENEFICIARY_UPDATE,
ROWS_PER_PAGE_OPTIONS,
CLEARED_STATE_FILTER,
BENEFIT_PLAN_LABEL,
MODULE_NAME,
} from '../constants';
import BenefitPlanGroupBeneficiariesFilter from './BenefitPlanGroupBeneficiariesFilter';
import BeneficiaryStatusPicker from '../pickers/BeneficiaryStatusPicker';
import { applyNumberCircle } from '../util/searcher-utils';


Check failure on line 41 in src/components/BenefitPlanGroupBeneficiariesSearcher.js

View workflow job for this annotation

GitHub Actions / lint

More than 1 blank line not allowed
function BenefitPlanGroupBeneficiariesSearcher({
rights,
Expand Down Expand Up @@ -152,6 +157,8 @@ function BenefitPlanGroupBeneficiariesSearcher({
};

const [failedExport, setFailedExport] = useState(false);
const [appliedCustomFilters, setAppliedCustomFilters] = useState([CLEARED_STATE_FILTER]);
const [appliedFiltersRowStructure, setAppliedFiltersRowStructure] = useState([CLEARED_STATE_FILTER]);

const isRowDisabled = (_, groupBeneficiary) => (
updatedGroupBeneficiaries.some((item) => item.id === groupBeneficiary.id));
Expand Down Expand Up @@ -183,6 +190,11 @@ function BenefitPlanGroupBeneficiariesSearcher({
readOnly={readOnly}
/>
);

useEffect(() => {
// refresh when appliedCustomFilters is changed
}, [appliedCustomFilters]);

return (
!!benefitPlan?.id && (
<div>
Expand Down Expand Up @@ -219,6 +231,15 @@ function BenefitPlanGroupBeneficiariesSearcher({
cacheFiltersKey="benefitPlanGroupBeneficiaryFilterCache"
cachePerTab
cacheTabName={`${benefitPlan?.id}-${status}`}
isCustomFiltering
objectForCustomFiltering={benefitPlan}
moduleName={MODULE_NAME}
objectType={BENEFIT_PLAN_LABEL}
appliedCustomFilters={appliedCustomFilters}
setAppliedCustomFilters={setAppliedCustomFilters}
appliedFiltersRowStructure={appliedFiltersRowStructure}
setAppliedFiltersRowStructure={setAppliedFiltersRowStructure}
applyNumberCircle={applyNumberCircle}
rowDisabled={isRowDisabled}
rowLocked={isRowDisabled}
/>
Expand Down

0 comments on commit 618633c

Please sign in to comment.