Skip to content

WEB-966: Prevent duplicate disbursement submissions#3616

Open
Mahesh-Gite-28 wants to merge 1 commit into
openMF:devfrom
Mahesh-Gite-28:WEB-966-prevent-duplicate-disbursement-submissions
Open

WEB-966: Prevent duplicate disbursement submissions#3616
Mahesh-Gite-28 wants to merge 1 commit into
openMF:devfrom
Mahesh-Gite-28:WEB-966-prevent-duplicate-disbursement-submissions

Conversation

@Mahesh-Gite-28
Copy link
Copy Markdown
Contributor

@Mahesh-Gite-28 Mahesh-Gite-28 commented May 25, 2026

Description

This PR prevents duplicate disbursement submissions in the "Disburse to Savings" workflow.

Previously, rapid repeated clicks on the Submit button could dispatch multiple concurrent HTTP POST requests before the initial request completed and navigation occurred.

This resulted in backend validation conflicts such as:

  • "Loan Disbursal is not allowed. Loan Account is not in approved and not disbursed state."
  • "Loan can't be disbursed, disburse amount is exceeding approved principal."

The issue occurred because the submit button remained interactive during the async request lifecycle.

This PR introduces:

  • local isSubmitting state locking
  • immediate submit button disabling during request processing
  • proper unlock handling on request failure
  • markForCheck() updates for OnPush change detection compatibility

Screenshots, if any

Attached:

  • before fix video
Before.Bug.mp4
  • after fix video
After.Fix.mp4

Checklist

  • If you have multiple commits please combine them into one commit by squashing them.
  • Read and understood the contribution guidelines at web-app/.github/CONTRIBUTING.md.

Summary by CodeRabbit

  • Bug Fixes
    • The Submit button for loan disbursement now remains disabled while a request is being processed, preventing users from accidentally submitting multiple duplicate disbursement requests.
    • Error handling has been improved to properly reset the form submission state when a disbursement request fails, allowing users to immediately retry without refreshing the page.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "pre_merge_checks"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

The component prevents duplicate disbursement submissions by introducing submission-state tracking. A new isSubmitting flag is set to true before the async API call, guards the submit method to early-return if already submitting, and is reset to false on error. The template disables the Submit button while submitting.

Changes

Duplicate Submission Prevention

Layer / File(s) Summary
Component setup for submission state tracking
src/app/loans/loans-view/loan-account-actions/disburse-to-savings-account/disburse-to-savings-account.component.ts
Imports ChangeDetectorRef and injects it as cdr. Adds an isSubmitting boolean flag initialized to false to track whether a disbursement submission is currently in flight.
Submit method with duplicate prevention guard
src/app/loans/loans-view/loan-account-actions/disburse-to-savings-account/disburse-to-savings-account.component.ts
The submit() method early-returns if the form is invalid or a submission is already in progress. When valid, it sets isSubmitting = true and calls markForCheck() to ensure immediate UI updates.
Subscription refactoring and button disabling
src/app/loans/loans-view/loan-account-actions/disburse-to-savings-account/disburse-to-savings-account.component.ts, disburse-to-savings-account.component.html
The API subscription now uses explicit next and error handlers. The error handler resets isSubmitting to false and marks for check. The template disables the Submit button when either the form is invalid or a submission is in progress.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • openMF/web-app#3609: Applies the same duplicate submission prevention pattern with isSubmitting flag, markForCheck(), and button disabling to the make-repayment loan action component.

Suggested reviewers

  • alberto-art3ch
  • adamsaghy
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main objective of the changeset: preventing duplicate disbursement submissions through state locking and UI disabling logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Flashl3opard
Copy link
Copy Markdown

LGTM

Copy link
Copy Markdown
Collaborator

@alberto-art3ch alberto-art3ch left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants