Skip to content

Commit a03352e

Browse files
committed
fix(benefit-plan): fix schema validation and action button tooltips
- Correct the action type value for `BENEFIT_PLAN_SCHEMA_SET_VALID` in the reducer to prevent it from overriding the name validation. - Initialize `validationFields` in the default reducer state. - Handle undefined schema validation state gracefully in `isValid` check. - Hide tooltips on the 'delete' and 'stop' action buttons when they are disabled. - Remove `displayZero` from the max beneficiaries input field to improve usability.
1 parent f889ca3 commit a03352e

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/components/BenefitPlanHeadPanel.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ class BenefitPlanHeadPanel extends FormPanel {
131131
<StyledGridItem size={3}>
132132
<NumberInput
133133
min={0}
134-
displayZero
135134
module="socialProtection"
136135
label="benefitPlan.maxBeneficiaries"
137136
onChange={(v) => {

src/pages/BenefitPlanPage.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function BenefitPlanPage({
115115
};
116116

117117
const isValid = () => (
118-
isBenefitPlanNameValid && isBenefitPlanCodeValid && isBenefitPlanSchemaValid
118+
isBenefitPlanNameValid && isBenefitPlanCodeValid && (isBenefitPlanSchemaValid ?? true)
119119
);
120120

121121
const doesBenefitPlanChange = () => {
@@ -201,14 +201,14 @@ function BenefitPlanPage({
201201
icon: <DeleteIcon />,
202202
handler: openDeleteBenefitPlanConfirmDialog,
203203
disabled: !benefitPlan?.id || submittingMutation,
204-
tooltip: formatMessage(intl, 'socialProtection', 'benefitPlan.deleteButton.tooltip'),
204+
tooltip: (!benefitPlan?.id || submittingMutation) ? undefined : formatMessage(intl, 'socialProtection', 'benefitPlan.deleteButton.tooltip'),
205205
},
206206
{
207207
name: 'stop',
208208
icon: <PauseIcon />,
209209
handler: openStopBenefitPlanConfirmDialog,
210210
disabled: !benefitPlan?.id || submittingMutation,
211-
tooltip: formatMessage(intl, 'socialProtection', 'benefitPlan.closeButton.tooltip'),
211+
tooltip: (!benefitPlan?.id || submittingMutation) ? undefined : formatMessage(intl, 'socialProtection', 'benefitPlan.closeButton.tooltip'),
212212
},
213213
]}
214214
/>

src/reducer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const ACTION_TYPE = {
2929
BENEFIT_PLAN_SCHEMA_FIELDS_VALIDATION: 'BENEFIT_PLAN_SCHEMA_FIELDS_VALIDATION',
3030
BENEFIT_PLAN_CODE_SET_VALID: 'BENEFIT_PLAN_CODE_SET_VALID',
3131
BENEFIT_PLAN_NAME_SET_VALID: 'BENEFIT_PLAN_NAME_SET_VALID',
32-
BENEFIT_PLAN_SCHEMA_SET_VALID: 'BENEFIT_PLAN_NAME_SET_VALID',
32+
BENEFIT_PLAN_SCHEMA_SET_VALID: 'BENEFIT_PLAN_SCHEMA_SET_VALID',
3333
SEARCH_BENEFICIARIES: 'BENEFICIARY_BENEFICIARIES',
3434
SEARCH_PROJECT_BENEFICIARIES: 'PROJECT_BENEFICIARIES',
3535
SEARCH_GROUP_BENEFICIARIES: 'GROUP_BENEFICIARY_GROUP_BENEFICIARIES',
@@ -142,6 +142,11 @@ function reducer(
142142
projectBeneficiariesPageInfo: {},
143143
projectBeneficiariesTotalCount: 0,
144144
errorProjectBeneficiaries: null,
145+
validationFields: {
146+
benefitPlanName: { isValid: true },
147+
benefitPlanCode: { isValid: true },
148+
benefitPlanSchema: { isValid: true },
149+
},
145150
},
146151
action,
147152
) {

0 commit comments

Comments
 (0)