Skip to content

Disable Save when payment plan code is taken#108

Open
Shahzaibahmad97 wants to merge 1 commit intodevelopfrom
fix/payment-plan-code-taken-validation
Open

Disable Save when payment plan code is taken#108
Shahzaibahmad97 wants to merge 1 commit intodevelopfrom
fix/payment-plan-code-taken-validation

Conversation

@Shahzaibahmad97
Copy link
Copy Markdown

@Shahzaibahmad97 Shahzaibahmad97 commented Apr 16, 2026

Description

The payment-plan creation form previously allowed users to attempt a Save even when the asynchronous code-uniqueness validation reported that the entered code was already taken. When the conflict was reported, the field-level error rendered the raw translation key paymentPlan.codeTaken instead of a human-readable message because no English string was registered for that key.

This PR fixes both issues:

  1. Adds the missing paymentPlan.codeTaken English translation so the field-level error displays "Payment plan code already exists" instead of the raw key.
  2. Includes isCodeValid in the form's canSave() predicate so the Save button is disabled while the duplicate-code error is active, mirroring the existing ContributionPlanForm pattern.

Type of Change

  • Feature
  • Bug fix
  • Chore (Refactor, Docs, CI/CD)
  • Other, please specify

Related Issue(s) / Task(s)

E2E Payment Tests


Changes

Translation

  • Add paymentPlan.codeTaken"Payment plan code already exists" in src/translations/en.json

Form Validation

  • Add this.props.isCodeValid check to canSave() in PaymentPlanForm.js
  • isCodeValid was already wired through mapStateToProps from state.contributionPlan?.validationFields?.paymentPlanCode?.isValid — no new redux plumbing needed

Behaviour Before / After

Scenario Before After
Type a duplicate code Raw key paymentPlan.codeTaken shown under the field Message "Payment plan code already exists" shown under the field
Save button while duplicate error is active Enabled (allows submit attempt) Disabled (prevents submit)
Save button after fixing the code to a unique value Enabled Enabled

Demo

To be added after manual verification.

Checklist

  • Translation key added matches the existing paymentPlan.* namespace convention
  • canSave() change matches the existing ContributionPlanForm / ContributionPlanBundleForm pattern (consistency across forms)
  • No new redux state introduced — reuses existing validationFields.paymentPlanCode.isValid
  • Build succeeds (npm run build)
  • Verified manually in the running stack with E2E coverage in openimis-dist_dkr

Add the missing paymentPlan.codeTaken English translation so the
duplicate-code error renders the user-facing message instead of the raw
key.  Include isCodeValid in canSave() so the Save button is disabled
while the async code-uniqueness validation reports a conflict, matching
the ContributionPlanForm pattern.
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant