Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CM-108: add group detail view #16

Merged
merged 8 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/components/BenefitPlanFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { withTheme, withStyles } from '@material-ui/core/styles';
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';

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

Expand Down Expand Up @@ -110,6 +111,23 @@ function BenefitPlanFilter({
label={formatMessage(intl, 'socialProtection', 'benefitPlan.isDeleted')}
/>
</Grid>
{showStatuses && (
<Grid item xs={2} className={classes.item}>
<BeneficiaryStatusPicker
label="beneficiary.beneficiaryStatusPicker"
withNull
nullLabel={formatMessage(intl, 'socialProtection', 'any')}
value={filterValue('beneficiaryStatus')}
onChange={(value) => onChangeFilters([
{
id: 'beneficiaryStatus',
value,
filter: `beneficiaryStatus: "${value}"`,
},
])}
/>
</Grid>
)}
</Grid>
);
}
Expand Down
28 changes: 19 additions & 9 deletions src/components/BenefitPlanSearcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function BenefitPlanSearcher({
benefitPlansPageInfo,
benefitPlansTotalCount,
individualId,
beneficiaryStatus,
groupId,
}) {
const [benefitPlanToDelete, setBenefitPlanToDelete] = useState(null);
const [deletedBenefitPlanUuids, setDeletedBenefitPlanUuids] = useState([]);
Expand Down Expand Up @@ -106,12 +106,12 @@ function BenefitPlanSearcher({

function benefitPlanUpdatePageUrl(benefitPlan) {
return (`${modulesManager.getRef('socialProtection.route.benefitPlan')}`
+ `/${benefitPlan?.id}`);
+ `/${benefitPlan?.id}`);
}

const onDoubleClick = (benefitPlan, newTab = false) => rights.includes(RIGHT_BENEFIT_PLAN_UPDATE)
&& !deletedBenefitPlanUuids.includes(benefitPlan.id)
&& historyPush(modulesManager, history, 'socialProtection.route.benefitPlan', [benefitPlan?.id], newTab);
&& !deletedBenefitPlanUuids.includes(benefitPlan.id)
&& historyPush(modulesManager, history, 'socialProtection.route.benefitPlan', [benefitPlan?.id], newTab);

const onDelete = (benefitPlan) => setBenefitPlanToDelete(benefitPlan);

Expand Down Expand Up @@ -177,20 +177,30 @@ function BenefitPlanSearcher({
filter: `individualId: "${individualId}"`,
};
}
if (beneficiaryStatus !== null && beneficiaryStatus !== undefined) {
filters.beneficiaryStatus = {
value: beneficiaryStatus,
filter: `beneficiaryStatus: "${beneficiaryStatus}"`,
if (groupId !== null && groupId !== undefined) {
filters.groupId = {
value: groupId,
filter: `groupId: "${groupId}"`,
};
}
return filters;
};

const benefitPlanFilter = (props) => (
<BenefitPlanFilter
intl={props.intl}
classes={props.classes}
filters={props.filters}
onChangeFilters={props.onChangeFilters}
showStatuses={individualId ?? groupId}
/>
);

return (
<Searcher
key={JSON.stringify(defaultFilters())}
module="socialProtection"
FilterPane={BenefitPlanFilter}
FilterPane={benefitPlanFilter}
fetch={fetch}
items={benefitPlans}
itemsPageInfo={benefitPlansPageInfo}
Expand Down