Skip to content

Commit

Permalink
CM-812: updated benefit plan picker, added code of group for benefit …
Browse files Browse the repository at this point in the history
…group
  • Loading branch information
sniedzielski committed May 23, 2024
1 parent 47d5796 commit 539f631
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const BENEFICIARY_FULL_PROJECTION = () => [

const GROUP_BENEFICIARY_FULL_PROJECTION = () => [
'id',
'group {id}',
'group {id, code}',
'status',
];

Expand Down
16 changes: 15 additions & 1 deletion src/components/BenefitPlanGroupBeneficiariesFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { injectIntl } from 'react-intl';
import { Grid } from '@material-ui/core';
import { withTheme, withStyles } from '@material-ui/core/styles';
import { formatMessage } from '@openimis/fe-core';
import { formatMessage, TextInput } from '@openimis/fe-core';
import { defaultFilterStyles } from '../util/styles';
import BeneficiaryStatusPicker from '../pickers/BeneficiaryStatusPicker';

Expand All @@ -13,6 +13,20 @@ function BenefitPlanBeneficiariesFilter({

return (
<Grid container className={classes.form}>
<Grid item xs={2} className={classes.item}>
<TextInput
module="socialProtection"
label="group.code"
value={filterValue('code')}
onChange={(value) => onChangeFilters([
{
id: 'code',
value,
filter: `group_Code_Icontains: "${value}"`,
},
])}
/>
</Grid>
<Grid item xs={2} className={classes.item}>
<BeneficiaryStatusPicker
label="beneficiary.beneficiaryStatusPicker"
Expand Down
4 changes: 2 additions & 2 deletions src/components/BenefitPlanGroupBeneficiariesSearcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function BenefitPlanGroupBeneficiariesSearcher({
const fetch = (params) => fetchGroupBeneficiaries(params);

const headers = () => [
'socialProtection.groupBeneficiary.id',
'socialProtection.groupBeneficiary.code',
'socialProtection.groupBeneficiary.status',
];

Expand Down Expand Up @@ -99,7 +99,7 @@ function BenefitPlanGroupBeneficiariesSearcher({

const itemFormatters = () => {
const result = [
(groupBeneficiary) => groupBeneficiary.group.id,
(groupBeneficiary) => groupBeneficiary.group.code,
(groupBeneficiary) => (rights.includes(RIGHT_BENEFICIARY_UPDATE) ? (
<BeneficiaryStatusPicker
withLabel={false}
Expand Down
6 changes: 5 additions & 1 deletion src/pickers/BenefitPlanPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function BenefitPlanPicker(props) {
onChange,
filter,
filterSelectedOptions,
type = 'INDIVIDUAL',
} = props;

const modulesManager = useModulesManager();
Expand All @@ -38,6 +39,7 @@ function BenefitPlanPicker(props) {
id
code
name
type
jsonExt
}
}
Expand All @@ -48,7 +50,9 @@ function BenefitPlanPicker(props) {
{ skip: true },
);

const benefitPlans = data?.benefitPlan?.edges.map((edge) => edge.node) ?? [];
const benefitPlans = data?.benefitPlan?.edges
.map((edge) => edge.node)
.filter((node) => node.type === type) ?? [];
const shouldShowTooltip = benefitPlans?.length >= BENEFIT_PLANS_QUANTITY_LIMIT && !value && !currentString;

return (
Expand Down
4 changes: 3 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,7 @@
"socialProtection.benefitPlan.searcherResultsTitleHistory": "{benefitPlansHistoryTotalCount} Historical Records Found",
"socialProtection.benefitPlan.benefitPlanSchema.label": "Benefit Plan Schema",
"socialProtection.benefitPlan.schema.showSchema": "Show Schema",
"socialProtection.benefitPlanTasks.label": "Tasks"
"socialProtection.benefitPlanTasks.label": "Tasks",
"socialProtection.group.code": "Code",
"socialProtection.groupBeneficiary.code": "Code"
}

0 comments on commit 539f631

Please sign in to comment.