Skip to content

Commit

Permalink
Merge pull request #75 from openimis/feature/CM-776
Browse files Browse the repository at this point in the history
CM-776: Make periodicity of the BenefitPlan paymentPlan not mandatory
  • Loading branch information
jdolkowski authored Mar 13, 2024
2 parents ae9dbb8 + a996b30 commit bbfc064
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/components/PaymentPlanHeadPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ class PaymentPlanHeadPanel extends FormPanel {
const objectBenefitPlan = typeof paymentPlan.productOrBenefitPlan === 'object' ?
paymentPlan.productOrBenefitPlan : JSON.parse(paymentPlan.productOrBenefitPlan || '{}');
paymentPlan.benefitPlan = objectBenefitPlan;
if (paymentPlanType === 'benefitplan' || paymentPlanType === 'benefit plan') {
paymentPlan.periodicity = 1;
this.state.data.periodicity = paymentPlan.periodicity;
}
return (
<Fragment>
<Grid container className={classes.tableTitle}>
Expand Down Expand Up @@ -252,20 +256,22 @@ class PaymentPlanHeadPanel extends FormPanel {
onChange={(v) => this.updateAttribute("benefitPlan", v)}
/>
</Grid>
<Grid item xs={GRID_ITEM_SIZE} className={classes.item}>
<NumberInput
module="contributionPlan"
label="periodicity"
required
/**
* @see min set to @see EMPTY_PERIODICITY_FILTER when filter unset to avoid @see NumberInput error message
*/
min={!!paymentPlan.periodicity ? MIN_PERIODICITY_VALUE : EMPTY_PERIODICITY_VALUE}
max={MAX_PERIODICITY_VALUE}
value={!!paymentPlan.periodicity ? paymentPlan.periodicity : null}
onChange={(v) => this.updateAttribute("periodicity", v)}
/>
</Grid>
{paymentPlanType !== 'benefitplan' && paymentPlanType !== 'benefit plan' && (
<Grid item xs={GRID_ITEM_SIZE} className={classes.item}>
<NumberInput
module="contributionPlan"
label="periodicity"
required
/**
* @see min set to @see EMPTY_PERIODICITY_FILTER when filter unset to avoid @see NumberInput error message
*/
min={!!paymentPlan.periodicity ? MIN_PERIODICITY_VALUE : EMPTY_PERIODICITY_VALUE}
max={MAX_PERIODICITY_VALUE}
value={!!paymentPlan.periodicity ? paymentPlan.periodicity : null}
onChange={(v) => this.updateAttribute("periodicity", v)}
/>
</Grid>
)}
<Grid item xs={GRID_ITEM_SIZE} className={classes.item}>
<PublishedComponent
pubRef="core.DatePicker"
Expand Down

0 comments on commit bbfc064

Please sign in to comment.