android-client icon indicating copy to clipboard operation
android-client copied to clipboard

feat(loan): Implement undo approval screen

Open Arinyadav1 opened this issue 7 months ago • 9 comments

Fixes - Jira-#682

@coderabbitai make a summary description of this PR

Screen_recording_20260407_192954.webm

Summary by CodeRabbit

  • New Features

    • Users can undo previously approved loans and submit an optional note.
    • Added an Undo Approval screen with navigation, ViewModel-driven form, loading indicator, and error dialog.
    • Introduced a resizable multiline text field for entering notes.
  • Chores

    • Improved offline/network handling for the undo flow and updated internal wiring and package metadata.

Arinyadav1 avatar Apr 07 '26 14:04 Arinyadav1

[!NOTE]

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • [ ] ▶️ Resume reviews
  • [ ] 🔍 Trigger review

Walkthrough

Adds an end-to-end "undo loan approval" feature: API endpoint, network datamanager, repository method and implementation, request model, DI/viewModel registration, navigation route, Compose screen and dialog, resizable text field component, string resource, and related build/podspec and network utilities.

Changes

Cohort / File(s) Summary
Network API & Datamanager
core/network/src/commonMain/kotlin/com/mifos/core/network/services/LoanService.kt, core/network/src/commonMain/kotlin/com/mifos/core/network/datamanager/DataManagerLoan.kt
Added undoLoanApproval API endpoint in LoanService and a suspend wrapper in DataManagerLoan that calls the service and throws on non-success responses.
Repository & Model
core/data/src/commonMain/kotlin/com/mifos/core/data/repository/LoanAccountApprovalRepository.kt, core/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/LoanAccountApprovalRepositoryImp.kt, core/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/LoanUndoApprovalRequest.kt
Introduced LoanUndoApprovalRequest model; repository interface gains suspend fun undoLoanApproval(...) : DataState<Unit>; implementation injects DataManagerLoan, dispatcher/network utilities, and implements the suspend method with network checks and error mapping.
Network Utilities
core/data/src/commonMain/kotlin/com/mifos/core/data/util/NetworkMonitor.kt
Added NetworkUnavailableException, requireOnline() suspend extension, and withNetworkCheck(...) Flow helper; clarified isOnline semantics.
Design System
core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosOutlinedTextField.kt
Added MifosResizableOutlinedTextField composable: multi-line OutlinedTextField with draggable resize handle and preview.
Feature — Navigation & DI
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/di/LoanModule.kt, feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.kt, feature/loan/src/commonMain/composeResources/values/strings.xml
Registered LoanUndoApprovalViewModel in DI, added string resource feature_loan_undo_approval_note, and registered undo-approval destination in loan navigation graph.
Feature — UI (route, screen, viewmodel)
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanUndoApproval/LoanUndoApprovalRoute.kt, .../LoanUndoApprovalScreen.kt, .../LoanUndoApprovalViewModel.kt
Added serializable route and navigation helpers; new composables for screen/content/dialog; LoanUndoApprovalViewModel handles note input, submit/retry, calls repository, and emits navigation events.
Build / Podspec
cmp-shared/cmp_shared.podspec, core/data/build.gradle.kts
Bumped podspec version and adjusted resource path separator; added api(projects.coreBase.common) dependency to core/data.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI as LoanUndoApprovalScreen
    participant VM as LoanUndoApprovalViewModel
    participant Repo as LoanAccountApprovalRepository
    participant DML as DataManagerLoan
    participant API as LoanService

    User->>UI: Enter note and tap Submit
    UI->>VM: dispatch OnSubmit
    VM->>Repo: undoLoanApproval(loanId, LoanUndoApprovalRequest)
    Repo->>DML: dataManagerLoan.undoLoanApproval(loanId, noteRequest)
    DML->>API: POST /loans/{loanId}?command=undoApproval (body: note)
    API-->>DML: HttpResponse (success/failure)
    DML-->>Repo: return or throw on error
    Repo-->>VM: DataState.Success or DataState.Error
    VM-->>UI: update dialogState or emit NavigationBack
    UI-->>User: show success (navigate back) or error dialog

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • biplab1
  • revanthkumarJ
  • Nagarjuna0033

Poem

"I hopped through code with tiny paws,
Unwound an approval with gentle claws,
A note, a tug, a soft undo —
Back it goes, the loan bids adieu 🥕
— Rabbit dev, nibbling refs anew."

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.52% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding an undo approval screen for loans, which aligns with the PR's primary objective and the substantial new UI, routing, and ViewModel additions.

✏️ 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.

coderabbitai[bot] avatar Apr 07 '26 14:04 coderabbitai[bot]

@niyajali please review it again

Arinyadav1 avatar Apr 09 '26 05:04 Arinyadav1

@coderabbitai Improve PR title based on github.com/openMF/mobile-wallet/wiki/Commit-style-guide. Give us just the title.

biplab1 avatar Apr 13 '26 04:04 biplab1

[!TIP] For best results, initiate chat on the files or code changes.

@biplab1: Based on the commit style guide (conventional commits format with lowercase present-tense summary), here is the improved PR title:

feat(loan): implement undo loan approval screen

coderabbitai[bot] avatar Apr 13 '26 04:04 coderabbitai[bot]

@Arinyadav1 Why are we permitting users to access the undo approval screen when the loan account has not yet been approved?

niyajali avatar Apr 23 '26 09:04 niyajali

@niyajali This functionality will be implement when action UI will build and this is only undo approval screen.

In actions show undo approval screen action when user permitted to undo approval otherwise doesn't show undo approval action

Arinyadav1 avatar Apr 23 '26 09:04 Arinyadav1

@Arinyadav1 Please resolve the merge conflicts.

biplab1 avatar May 15 '26 11:05 biplab1