Skip to content

WEB-657: WorkingCapital Loan approve or reject actions#3416

Open
alberto-art3ch wants to merge 1 commit intoopenMF:devfrom
alberto-art3ch:WEB-657/workingcapital-loan-approve-reject
Open

WEB-657: WorkingCapital Loan approve or reject actions#3416
alberto-art3ch wants to merge 1 commit intoopenMF:devfrom
alberto-art3ch:WEB-657/workingcapital-loan-approve-reject

Conversation

@alberto-art3ch
Copy link
Collaborator

@alberto-art3ch alberto-art3ch commented Mar 19, 2026

Description

Now that we have the WorkingCapital Loan account creation we need to approve or reject the account

WEB-657

Screenshots

Screenshot 2026-03-19 at 3 44 04 PM

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • 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

  • New Features

    • Added working-capital support for approve, reject, and undo-approval workflows.
  • UI/UX Updates

    • Loan amount labels now show "Total Payment + Volume" where applicable.
    • "Available Disbursement Amount" field is now conditional based on loan product type.
  • Localization

    • Added "Volume" label translations across multiple locales (including EN, DE, ES, FR, IT, CS, KO, LT, LV, NE, PT, SW, and others).

@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 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(s) in object: '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

Update templates to use a new "Volume" label in working-capital contexts, add the "Volume" translation across locales, and change loan action components to use command-driven conditional service calls (approve/reject/undo) with improved error handling and conditional field rendering.

Changes

Cohort / File(s) Summary
Template label updates
src/app/loans/loans-account-stepper/.../loans-account-terms-step.component.html, src/app/loans/loans-view/general-tab/general-tab.component.html
Replaced the second label shown with labels.inputs.Volume (translated) where working-capital contexts display total payment; no control or binding changes.
Approve loan — template & logic
src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.html, src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.ts
Made "Available Disbursement Amount" field conditional on isLoanProduct; removed one delinquency-data assignment; introduced loanCommand='approve', built a conditional request$ that calls loanActionButtons() for loan products or applyWorkingCapitalLoanAccountCommand() for working-capital, added unsupported-product form error and subscription error handling.
Other loan action components
src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts, src/app/loans/loans-view/loan-account-actions/undo-approval/undo-approval.component.ts
Introduced loanCommand constants ('reject', 'undoapproval') and conditional service calls: loanActionButtons() for loan products or applyWorkingCapitalLoanAccountCommand() for working-capital; navigate back on completion.
Translations (added Volume key)
src/assets/translations/cs-CS.json, src/assets/translations/de-DE.json, src/assets/translations/en-US.json, src/assets/translations/es-CL.json, src/assets/translations/es-MX.json, src/assets/translations/fr-FR.json, src/assets/translations/it-IT.json, src/assets/translations/ko-KO.json, src/assets/translations/lt-LT.json, src/assets/translations/lv-LV.json, src/assets/translations/ne-NE.json, src/assets/translations/pt-PT.json, src/assets/translations/sw-SW.json
Added Volume translation key/value in each locale file (no other JSON changes).

Sequence Diagram(s)

sequenceDiagram
    participant UI as Approve/Reject/Undo Component
    participant Auth as Auth/Caller (component state)
    participant Service as LoanService
    participant Router as Router

    UI->>Auth: determine isLoanProduct / isWorkingCapital
    alt isLoanProduct
        UI->>Service: loanActionButtons(loanId, loanCommand, data)
    else isWorkingCapital
        UI->>Service: applyWorkingCapitalLoanAccountCommand(loanId, loanCommand, data)
    else unsupported
        UI-->>UI: set form error {unsupportedProductType: true} and return
    end
    Service-->>UI: next / success
    UI->>Router: gotoLoanDefaultView()
    Service-->>UI: error
    UI-->>UI: set form error {submitFailed: true}
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • adamsaghy
  • IOhacker
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'WEB-657: WorkingCapital Loan approve or reject actions' directly and specifically describes the main changes in the pull request—adding approve and reject functionality for WorkingCapital Loan accounts, which aligns with the modifications across component templates and service implementations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (4)
src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts (1)

89-96: Avoid any in subscribe callbacks here as well.

The callback payload is unused, so the any annotation can be removed for stricter typing.

♻️ Proposed fix
-      this.loanService.loanActionButtons(this.loanId, loanCommand, data).subscribe((response: any) => {
+      this.loanService.loanActionButtons(this.loanId, loanCommand, data).subscribe(() => {
         this.gotoLoanDefaultView();
       });
@@
-        .subscribe((response: any) => {
+        .subscribe(() => {
           this.gotoLoanDefaultView();
         });

Based on learnings: "avoid using Observable as a project-wide pattern for API responses."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts`
around lines 89 - 96, The subscribe callbacks for
loanService.loanActionButtons(...) and
loanService.applyWorkingCapitalLoanAccountCommand(...) use the unused parameter
typed as any; remove the unused parameter (or replace with a properly typed
response type) from both subscribe handlers to avoid using any. Update the calls
around loanActionButtons and applyWorkingCapitalLoanAccountCommand so the
subscribe callbacks simply call gotoLoanDefaultView() with no "response: any"
parameter, or substitute a concrete response type if you expect to use the
payload later.
src/app/loans/loans-view/loan-account-actions/undo-approval/undo-approval.component.ts (1)

49-56: Remove unnecessary any in subscribe callbacks.

response is unused in both callbacks, so any can be dropped entirely to keep typing strict.

♻️ Proposed fix
-        .subscribe((response: any) => {
+        .subscribe(() => {
           this.gotoLoanDefaultView();
         });
@@
-        .subscribe((response: any) => {
+        .subscribe(() => {
           this.gotoLoanDefaultView();
         });

As per coding guidelines src/app/**/*.ts: "Use TypeScript for all application code with strict typing conventions."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/app/loans/loans-view/loan-account-actions/undo-approval/undo-approval.component.ts`
around lines 49 - 56, Remove the unnecessary unused `any` parameter from the
subscribe callbacks so the handlers use no parameters (or an explicit empty
parameter list) to keep typing strict; update the two subscribe calls (the one
that calls this.gotoLoanDefaultView() after the initial apply command and the
one on this.loanService.applyWorkingCapitalLoanAccountCommand(this.loanId,
loanCommand, { note: this.note.value })) by deleting `(response: any)` and using
`()` instead.
src/assets/translations/ne-NE.json (1)

2720-2720: Please verify the Nepali terminology for “Volume.”

Line 2720 uses "भोल्युमेन", which looks like a transliteration and may read less naturally for Nepali users in a financial context. Please confirm with a native reviewer/localization glossary (e.g., whether "परिमाण"/"मात्रा" is preferred) to keep terminology consistent and user-friendly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/assets/translations/ne-NE.json` at line 2720, The translation for the
JSON key "Volume" currently uses the transliteration "भोल्युमेन"; verify with a
native Nepali reviewer or the localization glossary whether a more natural term
like "परिमाण" or "मात्रा" should be used and update the value for the "Volume"
key accordingly, keeping punctuation and JSON formatting intact and ensuring
consistency with related keys (e.g., any other volume/quantity labels) across
the ne-NE translations.
src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html (1)

29-29: Consider using a single translation key instead of concatenating two separate translations.

Concatenating two translate pipes ('labels.inputs.Total Payment' + 'labels.inputs.Volume') can cause i18n issues because word order and phrasing differ across languages. Translators also lose context when each part is translated separately.

🌐 Proposed refactor for better i18n support

Create a single translation key for the complete label:

-        <mat-label>{{ 'labels.inputs.Total Payment' | translate }} {{ 'labels.inputs.Volume' | translate }}</mat-label>
+        <mat-label>{{ 'labels.inputs.Total Payment Volume' | translate }}</mat-label>

Then add the new key to all locale files:

"labels": {
  "inputs": {
    "Total Payment Volume": "Total Payment Volume"
  }
}

(Adjust the translation text appropriately for each locale.)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html`
at line 29, The template concatenates two translate pipes in the mat-label ({{
'labels.inputs.Total Payment' | translate }} {{ 'labels.inputs.Volume' |
translate }}), which breaks i18n grammar; replace the two-part translation with
a single translation key (e.g., 'labels.inputs.Total Payment Volume') and update
the locale files accordingly, then change the template to use just that single
key in the mat-label so translators can provide correct phrasing for
LoansAccountTermsStepComponent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app/loans/loans-view/general-tab/general-tab.component.html`:
- Around line 271-272: The label currently always renders "Total Payment
Volume"; update the template near the span that outputs {{ 'labels.inputs.Total
Payment' | translate }} and {{ 'labels.inputs.Volume' | translate }} so the
"Volume" translation is only included for Working Capital loans; wrap the Volume
part in an Angular conditional (e.g., *ngIf="isWorkingCapital(loan)" or use a
ternary in the binding checking loan.productType/loan.type ===
'WORKING_CAPITAL') and keep non-working-capital loans showing just the amount
label. Ensure you reference the component method/property (isWorkingCapital or
loan.productType/loan.type) that determines working-capital status.

In
`@src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.ts`:
- Around line 120-131: Current flow silently does nothing when neither
this.isLoanProduct nor this.isWorkingCapital is true and both HTTP calls ignore
errors; update the approve path to explicitly handle unsupported product types
and surface API errors: keep the existing branches using
loanService.loanActionButtons(this.loanId, ...) and
loanService.applyWorkingCapitalLoanAccountCommand(this.loanId, ...), but add
error handlers to the subscribe (or switch to pipe + catchError) to show a
user-facing error/toast and avoid calling gotoLoanDefaultView on failure, and
add an else branch that logs/alerts an unsupported product type for the current
loanId so the no-op path is eliminated.

In `@src/assets/translations/lt-LT.json`:
- Line 2720: The translation value for the JSON key "Volume" currently reads
"Volumen" (incorrect language); update the value for the "Volume" key in the
lt-LT translation file to the correct Lithuanian term (e.g., "Tūris" or the
project-approved equivalent) so the entry becomes "Volume": "Tūris".

---

Nitpick comments:
In
`@src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html`:
- Line 29: The template concatenates two translate pipes in the mat-label ({{
'labels.inputs.Total Payment' | translate }} {{ 'labels.inputs.Volume' |
translate }}), which breaks i18n grammar; replace the two-part translation with
a single translation key (e.g., 'labels.inputs.Total Payment Volume') and update
the locale files accordingly, then change the template to use just that single
key in the mat-label so translators can provide correct phrasing for
LoansAccountTermsStepComponent.

In
`@src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts`:
- Around line 89-96: The subscribe callbacks for
loanService.loanActionButtons(...) and
loanService.applyWorkingCapitalLoanAccountCommand(...) use the unused parameter
typed as any; remove the unused parameter (or replace with a properly typed
response type) from both subscribe handlers to avoid using any. Update the calls
around loanActionButtons and applyWorkingCapitalLoanAccountCommand so the
subscribe callbacks simply call gotoLoanDefaultView() with no "response: any"
parameter, or substitute a concrete response type if you expect to use the
payload later.

In
`@src/app/loans/loans-view/loan-account-actions/undo-approval/undo-approval.component.ts`:
- Around line 49-56: Remove the unnecessary unused `any` parameter from the
subscribe callbacks so the handlers use no parameters (or an explicit empty
parameter list) to keep typing strict; update the two subscribe calls (the one
that calls this.gotoLoanDefaultView() after the initial apply command and the
one on this.loanService.applyWorkingCapitalLoanAccountCommand(this.loanId,
loanCommand, { note: this.note.value })) by deleting `(response: any)` and using
`()` instead.

In `@src/assets/translations/ne-NE.json`:
- Line 2720: The translation for the JSON key "Volume" currently uses the
transliteration "भोल्युमेन"; verify with a native Nepali reviewer or the
localization glossary whether a more natural term like "परिमाण" or "मात्रा"
should be used and update the value for the "Volume" key accordingly, keeping
punctuation and JSON formatting intact and ensuring consistency with related
keys (e.g., any other volume/quantity labels) across the ne-NE translations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bb5174f7-ae8a-41d3-bd23-532916a3f3a9

📥 Commits

Reviewing files that changed from the base of the PR and between 5e7705b and b5ef8b1.

📒 Files selected for processing (19)
  • src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html
  • src/app/loans/loans-view/general-tab/general-tab.component.html
  • src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.html
  • src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.ts
  • src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts
  • src/app/loans/loans-view/loan-account-actions/undo-approval/undo-approval.component.ts
  • src/assets/translations/cs-CS.json
  • src/assets/translations/de-DE.json
  • src/assets/translations/en-US.json
  • src/assets/translations/es-CL.json
  • src/assets/translations/es-MX.json
  • src/assets/translations/fr-FR.json
  • src/assets/translations/it-IT.json
  • src/assets/translations/ko-KO.json
  • src/assets/translations/lt-LT.json
  • src/assets/translations/lv-LV.json
  • src/assets/translations/ne-NE.json
  • src/assets/translations/pt-PT.json
  • src/assets/translations/sw-SW.json

Comment on lines +271 to 272
>{{ 'labels.inputs.Total Payment' | translate }} {{ 'labels.inputs.Volume' | translate }}:</span
>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Scope “Volume” label to Working Capital loans only.

Line 271 currently shows “Total Payment Volume” for every loan in this view. This should be conditional; non-working-capital loans should keep the amount label.

Proposed fix
-              <span class="flex-50"
-                >{{ 'labels.inputs.Total Payment' | translate }} {{ 'labels.inputs.Volume' | translate }}:</span
-              >
+              <span class="flex-50">
+                {{ 'labels.inputs.Total Payment' | translate }}
+                {{
+                  (loanProductType() === 'labels.catalogs.Working Capital'
+                    ? ('labels.inputs.Volume' | translate)
+                    : ('labels.inputs.Amount' | translate))
+                }}:
+              </span>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/loans/loans-view/general-tab/general-tab.component.html` around lines
271 - 272, The label currently always renders "Total Payment Volume"; update the
template near the span that outputs {{ 'labels.inputs.Total Payment' | translate
}} and {{ 'labels.inputs.Volume' | translate }} so the "Volume" translation is
only included for Working Capital loans; wrap the Volume part in an Angular
conditional (e.g., *ngIf="isWorkingCapital(loan)" or use a ternary in the
binding checking loan.productType/loan.type === 'WORKING_CAPITAL') and keep
non-working-capital loans showing just the amount label. Ensure you reference
the component method/property (isWorkingCapital or loan.productType/loan.type)
that determines working-capital status.

@alberto-art3ch alberto-art3ch force-pushed the WEB-657/workingcapital-loan-approve-reject branch from b5ef8b1 to d0af128 Compare March 20, 2026 02:01
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts (1)

31-36: Consider stronger typing for the form.

The component uses UntypedFormGroup and UntypedFormBuilder. While this is functional, migrating to strictly-typed reactive forms (FormGroup<T>) would improve type safety and align with Angular's modern patterns.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts`
around lines 31 - 36, The component currently uses UntypedFormBuilder and
UntypedFormGroup (see RejectLoanComponent, formBuilder, and rejectLoanForm);
change these to typed reactive forms by replacing UntypedFormBuilder with
FormBuilder and define rejectLoanForm as FormGroup<YourFormType> (create an
interface/type describing form controls and their value types), update any form
creation calls in RejectLoanComponent to use this type (e.g.,
this.formBuilder.group<YourFormType>(...)) and adjust usages of controls to use
the typed keys so callers (value access, get, patchValue) benefit from
compile-time checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts`:
- Around line 87-98: The submission path for reject action lacks error handling,
silently no-ops when neither isLoanProduct nor isWorkingCapital is true, and
uses an unused any-typed response; update the method to: call
loanService.loanActionButtons(...) and
applyWorkingCapitalLoanAccountCommand(...) with subscribe handlers that handle
both next and error (on success call gotoLoanDefaultView(), on error log and
surface a user-facing message via the app's toast/snackbar service), remove or
replace the unused (response: any) with a concrete response type per API
contracts (or omit the param if unused), and add an else branch that logs/alerts
when no product type matches (or disables the action) to avoid silent no-op;
reference the existing symbols loanActionButtons,
applyWorkingCapitalLoanAccountCommand, gotoLoanDefaultView, isLoanProduct, and
isWorkingCapital when making changes.

---

Nitpick comments:
In
`@src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts`:
- Around line 31-36: The component currently uses UntypedFormBuilder and
UntypedFormGroup (see RejectLoanComponent, formBuilder, and rejectLoanForm);
change these to typed reactive forms by replacing UntypedFormBuilder with
FormBuilder and define rejectLoanForm as FormGroup<YourFormType> (create an
interface/type describing form controls and their value types), update any form
creation calls in RejectLoanComponent to use this type (e.g.,
this.formBuilder.group<YourFormType>(...)) and adjust usages of controls to use
the typed keys so callers (value access, get, patchValue) benefit from
compile-time checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6e75c5b8-033a-4f8e-940a-372da6a577bb

📥 Commits

Reviewing files that changed from the base of the PR and between b5ef8b1 and d0af128.

📒 Files selected for processing (19)
  • src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html
  • src/app/loans/loans-view/general-tab/general-tab.component.html
  • src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.html
  • src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.ts
  • src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts
  • src/app/loans/loans-view/loan-account-actions/undo-approval/undo-approval.component.ts
  • src/assets/translations/cs-CS.json
  • src/assets/translations/de-DE.json
  • src/assets/translations/en-US.json
  • src/assets/translations/es-CL.json
  • src/assets/translations/es-MX.json
  • src/assets/translations/fr-FR.json
  • src/assets/translations/it-IT.json
  • src/assets/translations/ko-KO.json
  • src/assets/translations/lt-LT.json
  • src/assets/translations/lv-LV.json
  • src/assets/translations/ne-NE.json
  • src/assets/translations/pt-PT.json
  • src/assets/translations/sw-SW.json
✅ Files skipped from review due to trivial changes (15)
  • src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.html
  • src/app/loans/loans-view/general-tab/general-tab.component.html
  • src/assets/translations/es-CL.json
  • src/assets/translations/ko-KO.json
  • src/assets/translations/en-US.json
  • src/assets/translations/fr-FR.json
  • src/assets/translations/lt-LT.json
  • src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.html
  • src/assets/translations/es-MX.json
  • src/assets/translations/it-IT.json
  • src/assets/translations/de-DE.json
  • src/assets/translations/sw-SW.json
  • src/assets/translations/ne-NE.json
  • src/assets/translations/lv-LV.json
  • src/assets/translations/pt-PT.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/app/loans/loans-view/loan-account-actions/undo-approval/undo-approval.component.ts
  • src/app/loans/loans-view/loan-account-actions/approve-loan/approve-loan.component.ts
  • src/assets/translations/cs-CS.json

Comment on lines +87 to 98
const loanCommand: string = 'reject';
if (this.isLoanProduct) {
this.loanService.loanActionButtons(this.loanId, 'reject', data).subscribe((response: any) => {
this.loanService.loanActionButtons(this.loanId, loanCommand, data).subscribe((response: any) => {
this.gotoLoanDefaultView();
});
} else if (this.isWorkingCapital) {
this.loanService
.applyWorkingCapitalLoanAccountCommand(this.loanId, loanCommand, data)
.subscribe((response: any) => {
this.gotoLoanDefaultView();
});
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Add error handling and consider edge case coverage.

Several concerns with this submission logic:

  1. No error handling: If the API call fails, users receive no feedback and the UI state becomes inconsistent.
  2. Unused response parameter: The response is typed but never used—either remove it or add proper typing per project conventions.
  3. Silent no-op: If neither isLoanProduct nor isWorkingCapital is true, the method silently does nothing.
Proposed fix with error handling
     const loanCommand: string = 'reject';
     if (this.isLoanProduct) {
-      this.loanService.loanActionButtons(this.loanId, loanCommand, data).subscribe((response: any) => {
-        this.gotoLoanDefaultView();
-      });
+      this.loanService.loanActionButtons(this.loanId, loanCommand, data).subscribe({
+        next: () => this.gotoLoanDefaultView(),
+        error: (err) => console.error('Failed to reject loan', err)
+      });
     } else if (this.isWorkingCapital) {
-      this.loanService
-        .applyWorkingCapitalLoanAccountCommand(this.loanId, loanCommand, data)
-        .subscribe((response: any) => {
-          this.gotoLoanDefaultView();
-        });
+      this.loanService
+        .applyWorkingCapitalLoanAccountCommand(this.loanId, loanCommand, data)
+        .subscribe({
+          next: () => this.gotoLoanDefaultView(),
+          error: (err) => console.error('Failed to reject working capital loan', err)
+        });
+    } else {
+      console.warn('Unknown loan product type; reject action not performed');
     }

Consider also showing a user-facing error notification (e.g., via a toast/snackbar service) rather than just logging to console. Based on learnings: avoid Observable<any> and introduce specific types for API responses as a cross-cutting refactor.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/app/loans/loans-view/loan-account-actions/reject-loan/reject-loan.component.ts`
around lines 87 - 98, The submission path for reject action lacks error
handling, silently no-ops when neither isLoanProduct nor isWorkingCapital is
true, and uses an unused any-typed response; update the method to: call
loanService.loanActionButtons(...) and
applyWorkingCapitalLoanAccountCommand(...) with subscribe handlers that handle
both next and error (on success call gotoLoanDefaultView(), on error log and
surface a user-facing message via the app's toast/snackbar service), remove or
replace the unused (response: any) with a concrete response type per API
contracts (or omit the param if unused), and add an else branch that logs/alerts
when no product type matches (or disables the action) to avoid silent no-op;
reference the existing symbols loanActionButtons,
applyWorkingCapitalLoanAccountCommand, gotoLoanDefaultView, isLoanProduct, and
isWorkingCapital when making changes.

@alberto-art3ch alberto-art3ch force-pushed the WEB-657/workingcapital-loan-approve-reject branch from d0af128 to caf14f7 Compare March 20, 2026 04:01
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