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-197: change holder to institution #43

Merged
merged 4 commits into from
Aug 8, 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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ None

## Other Modules Redux State Bindings
* `state.core.user`, to access user info (rights,...)
* `state.policyHolder`, to retrieve Policy Holders for their respective pickers

## Configurations Options
None
11 changes: 5 additions & 6 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
CLEAR, ERROR, REQUEST, SUCCESS,
} from './util/action-type';

const BENEFIT_PLAN_FULL_PROJECTION = (modulesManager) => [
const BENEFIT_PLAN_FULL_PROJECTION = () => [
'uuid',
'id',
'isDeleted',
Expand All @@ -30,8 +30,7 @@ const BENEFIT_PLAN_FULL_PROJECTION = (modulesManager) => [
'ceilingPerBeneficiary',
'beneficiaryDataSchema',
'jsonExt',
`holder${
modulesManager.getProjection('policyHolder.PolicyHolderPicker.projection')}`,
'institution',
];

const UPLOAD_HISTORY_FULL_PROJECTION = () => [
Expand Down Expand Up @@ -71,8 +70,8 @@ const WORKFLOWS_FULL_PROJECTION = () => [
'group',
];

export function fetchBenefitPlans(modulesManager, params) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better not do do this kind of changes in long living code, if fetchBenefitPlans would be used in other modules we're unaware of then functionality could break.

const payload = formatPageQueryWithCount('benefitPlan', params, BENEFIT_PLAN_FULL_PROJECTION(modulesManager));
export function fetchBenefitPlans(params) {
const payload = formatPageQueryWithCount('benefitPlan', params, BENEFIT_PLAN_FULL_PROJECTION);
return graphql(payload, ACTION_TYPE.SEARCH_BENEFIT_PLANS);
}

Expand Down Expand Up @@ -215,7 +214,7 @@ function formatBenefitPlanGQL(benefitPlan) {
${benefitPlan?.code ? `code: "${formatGQLString(benefitPlan.code)}"` : ''}
${benefitPlan?.maxBeneficiaries ? `maxBeneficiaries: ${benefitPlan.maxBeneficiaries}` : ''}
${benefitPlan?.ceilingPerBeneficiary ? `ceilingPerBeneficiary: "${benefitPlan.ceilingPerBeneficiary}"` : ''}
${benefitPlan?.holder?.id ? `holderId: "${benefitPlan.holder.id}"` : ''}
${benefitPlan?.institution ? `institution: "${formatGQLString(benefitPlan.institution)}"` : ''}
${benefitPlan?.type ? `type: ${benefitPlan.type}` : ''}
${benefitPlan?.dateValidFrom ? `dateValidFrom: "${dateTimeToDate(benefitPlan.dateValidFrom)}"` : ''}
${benefitPlan?.dateValidTo ? `dateValidTo: "${dateTimeToDate(benefitPlan.dateValidTo)}"` : ''}
Expand Down
6 changes: 3 additions & 3 deletions src/components/BenefitPackagePlanPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ class BenefitPackagePlanPanel extends FormPanel {
/>
</Grid>
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="policyHolder.PolicyHolderPicker"
<TextInput
module="socialProtection"
value={!!benefitPlan?.holder && benefitPlan.holder}
label="benefitPlan.institution"
value={benefitPlan?.institution ?? ''}
readOnly={readOnly}
/>
</Grid>
Expand Down
10 changes: 5 additions & 5 deletions src/components/BenefitPlanHeadPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ValidatedTextAreaInput,
TextAreaInput,
PublishedComponent,
TextInput,
} from '@openimis/fe-core';
import { injectIntl } from 'react-intl';
import { withTheme, withStyles } from '@material-ui/core/styles';
Expand Down Expand Up @@ -140,12 +141,11 @@ class BenefitPlanHeadPanel extends FormPanel {
/>
</Grid>
<Grid item xs={3} className={classes.item}>
<PublishedComponent
pubRef="policyHolder.PolicyHolderPicker"
<TextInput
module="socialProtection"
withNull
onChange={(v) => this.updateAttribute('holder', v)}
value={!!benefitPlan?.holder && benefitPlan.holder}
label="benefitPlan.institution"
onChange={(v) => this.updateAttribute('institution', v)}
value={benefitPlan?.institution ?? ''}
/>
</Grid>
<Grid item xs={3} className={classes.item}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/BenefitPlanSearcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function BenefitPlanSearcher({
prevSubmittingMutationRef.current = submittingMutation;
});

const fetch = (params) => fetchBenefitPlans(modulesManager, params);
const fetch = (params) => fetchBenefitPlans(params);

const headers = () => {
const headers = [
Expand Down
2 changes: 1 addition & 1 deletion src/components/BenefitPlanSearcherForEntities.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function BenefitPlanSearcherForEntities({
if (groupId) {
fetchBeneficiariesGroup(modulesManager, { group_Id: groupId });
}
fetchBenefitPlans(modulesManager, params);
fetchBenefitPlans(params);
};

const headers = () => {
Expand Down
34 changes: 8 additions & 26 deletions src/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,10 @@ function reducer(
...state,
fetchingBenefitPlans: false,
fetchedBenefitPlans: true,
benefitPlans: parseData(action.payload.data.benefitPlan)?.map((benefitPlan) => {
const response = ({
...benefitPlan,
id: decodeId(benefitPlan.id),
});
if (response?.holder?.id) {
response.holder = ({
...response.holder,
id: decodeId(response.holder.id),
});
}
return response;
}),
benefitPlans: parseData(action.payload.data.benefitPlan)?.map((benefitPlan) => ({
...benefitPlan,
id: decodeId(benefitPlan.id),
})),
benefitPlansPageInfo: pageInfo(action.payload.data.benefitPlan),
benefitPlansTotalCount: action.payload.data.benefitPlan ? action.payload.data.benefitPlan.totalCount : null,
errorBenefitPlans: formatGraphQLError(action.payload),
Expand All @@ -204,19 +195,10 @@ function reducer(
...state,
fetchingBenefitPlan: false,
fetchedBenefitPlan: true,
benefitPlan: parseData(action.payload.data.benefitPlan)?.map((benefitPlan) => {
const response = ({
...benefitPlan,
id: decodeId(benefitPlan.id),
});
if (response?.holder?.id) {
response.holder = ({
...response.holder,
id: decodeId(response.holder.id),
});
}
return response;
})?.[0],
benefitPlan: parseData(action.payload.data.benefitPlan)?.map((benefitPlan) => ({
...benefitPlan,
id: decodeId(benefitPlan.id),
}))?.[0],
errorBenefitPlan: null,
};
case SUCCESS(ACTION_TYPE.SEARCH_BENEFICIARIES):
Expand Down
1 change: 1 addition & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"socialProtection.benefitPlan.name": "Name",
"socialProtection.benefitPlan.type": "Type",
"socialProtection.benefitPlan.code": "Code",
"socialProtection.benefitPlan.institution": "Institution",
"socialProtection.benefitPlan.maxBeneficiaries": "Max Beneficiaries",
"socialProtection.benefitPlan.jsonExt": "json_ext",
"socialProtection.benefitPlan.schema": "Schema",
Expand Down