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-812: Added enrollment for group #91

Merged
merged 2 commits into from
May 24, 2024
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
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
8 changes: 6 additions & 2 deletions src/pickers/BenefitPlanPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TextField, Tooltip } from '@material-ui/core';
import {
Autocomplete, useModulesManager, useTranslations, useGraphqlQuery,
} from '@openimis/fe-core';
import { BENEFIT_PLANS_QUANTITY_LIMIT } from '../constants';
import { BENEFIT_PLANS_QUANTITY_LIMIT, BENEFIT_PLAN_TYPE } from '../constants';

function BenefitPlanPicker(props) {
const {
Expand All @@ -20,6 +20,7 @@ function BenefitPlanPicker(props) {
onChange,
filter,
filterSelectedOptions,
type = BENEFIT_PLAN_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"
}
Loading