Skip to content

Commit

Permalink
Revert "CM-197: change holder to institution (#43)"
Browse files Browse the repository at this point in the history
This reverts commit 9a4a1d2.
  • Loading branch information
dborowiecki authored Aug 8, 2023
1 parent 9a4a1d2 commit 2f7aa3e
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 24 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ 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: 6 additions & 5 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 = () => [
const BENEFIT_PLAN_FULL_PROJECTION = (modulesManager) => [
'uuid',
'id',
'isDeleted',
Expand All @@ -30,7 +30,8 @@ const BENEFIT_PLAN_FULL_PROJECTION = () => [
'ceilingPerBeneficiary',
'beneficiaryDataSchema',
'jsonExt',
'institution',
`holder${
modulesManager.getProjection('policyHolder.PolicyHolderPicker.projection')}`,
];

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

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

Expand Down Expand Up @@ -214,7 +215,7 @@ function formatBenefitPlanGQL(benefitPlan) {
${benefitPlan?.code ? `code: "${formatGQLString(benefitPlan.code)}"` : ''}
${benefitPlan?.maxBeneficiaries ? `maxBeneficiaries: ${benefitPlan.maxBeneficiaries}` : ''}
${benefitPlan?.ceilingPerBeneficiary ? `ceilingPerBeneficiary: "${benefitPlan.ceilingPerBeneficiary}"` : ''}
${benefitPlan?.institution ? `institution: "${formatGQLString(benefitPlan.institution)}"` : ''}
${benefitPlan?.holder?.id ? `holderId: "${benefitPlan.holder.id}"` : ''}
${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}>
<TextInput
<PublishedComponent
pubRef="policyHolder.PolicyHolderPicker"
module="socialProtection"
label="benefitPlan.institution"
value={benefitPlan?.institution ?? ''}
value={!!benefitPlan?.holder && benefitPlan.holder}
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,7 +9,6 @@ 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 @@ -141,11 +140,12 @@ class BenefitPlanHeadPanel extends FormPanel {
/>
</Grid>
<Grid item xs={3} className={classes.item}>
<TextInput
<PublishedComponent
pubRef="policyHolder.PolicyHolderPicker"
module="socialProtection"
label="benefitPlan.institution"
onChange={(v) => this.updateAttribute('institution', v)}
value={benefitPlan?.institution ?? ''}
withNull
onChange={(v) => this.updateAttribute('holder', v)}
value={!!benefitPlan?.holder && benefitPlan.holder}
/>
</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(params);
const fetch = (params) => fetchBenefitPlans(modulesManager, 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(params);
fetchBenefitPlans(modulesManager, params);
};

const headers = () => {
Expand Down
34 changes: 26 additions & 8 deletions src/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,19 @@ function reducer(
...state,
fetchingBenefitPlans: false,
fetchedBenefitPlans: true,
benefitPlans: parseData(action.payload.data.benefitPlan)?.map((benefitPlan) => ({
...benefitPlan,
id: decodeId(benefitPlan.id),
})),
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;
}),
benefitPlansPageInfo: pageInfo(action.payload.data.benefitPlan),
benefitPlansTotalCount: action.payload.data.benefitPlan ? action.payload.data.benefitPlan.totalCount : null,
errorBenefitPlans: formatGraphQLError(action.payload),
Expand All @@ -195,10 +204,19 @@ function reducer(
...state,
fetchingBenefitPlan: false,
fetchedBenefitPlan: true,
benefitPlan: parseData(action.payload.data.benefitPlan)?.map((benefitPlan) => ({
...benefitPlan,
id: decodeId(benefitPlan.id),
}))?.[0],
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],
errorBenefitPlan: null,
};
case SUCCESS(ACTION_TYPE.SEARCH_BENEFICIARIES):
Expand Down
1 change: 0 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"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

0 comments on commit 2f7aa3e

Please sign in to comment.