Skip to content

Conversation

@Arinyadav1
Copy link
Contributor

@Arinyadav1 Arinyadav1 commented Jan 27, 2026

Fixes - Jira-#630

Didn't create a Jira ticket, click here to create new.

Please Add Screenshots If there are any UI changes.

Before After

|
Screenshot 2026-01-27 124948
|
Screenshot 2026-01-27 163851
|

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

  • Run the static analysis check ./gradlew check or ci-prepush.sh to make sure you didn't break anything

  • If you have multiple commits please combine them into one commit by squashing them.

Summary by CodeRabbit

  • New Features

    • Added a full-screen loading overlay during collateral save operations.
    • New two-button action row (Back / Submit) and clearer no-items messaging.
  • Bug Fixes

    • Improved quantity input validation with inline error messages and safer total calculations.
  • Style

    • Redesigned collateral screen layout with persistent breadcrumb, streamlined fields, and updated spacing for cleaner presentation.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Refactors the ClientCollateral UI from a scaffold-based layout to a Column-based composition, converts quantity state from Int to String with validation and quantityError, adds isOverlayLoading and MifosProgressIndicatorOverlay, consolidates breadcrumb padding, and replaces the action row with MifosTwoButtonRow.

Changes

Cohort / File(s) Summary
Padding Modifier Consolidation
core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosBreadCrumb.kt
Replaced separate horizontal/vertical padding modifiers with a single padding(DesignToken.padding.large) on all sides in MifosBreadcrumbNavBar.
ClientCollateral Screen Layout Refactor
feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientCollateral/ClientCollateralScreen.kt
Replaced MifosScaffold flow with a direct Column-based layout using MifosBreadcrumbNavBar, title, conditional content for collateral list/no-options, a scrollable column for selection and read-only detail fields, interactive quantity input (String) with error binding, MifosTwoButtonRow for actions, and MifosProgressIndicatorOverlay. Removed scaffold-specific padding handling and deprecated UI components.
ClientCollateral ViewModel State & Logic
feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientCollateral/ClientCollateralViewModel.kt
Changed quantity: Intquantity: String; added quantityError: StringResource? and isOverlayLoading: Boolean. Integrated TextFieldsValidator for OnSave validation, updated OnQuantityChange to accept String and clear errors, adjusted total calculations to parse string quantity safely, refactored load/save flows (pattern when (val result = ...)), and updated dialog state usage (ShowStatusDialog import/alias).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Screen
    participant ViewModel
    participant Validator
    participant Repo

    User->>Screen: Select collateral / enter quantity
    Screen->>ViewModel: OnCollateralSelected / OnQuantityChange(quantity:String)
    ViewModel-->>Screen: Update UI state (selection, quantity, clear errors)

    User->>Screen: Tap Submit
    Screen->>ViewModel: OnSave
    ViewModel->>Validator: TextFieldsValidator.validate(fields)
    alt Validation passes
        Validator-->>ViewModel: Valid
        ViewModel->>ViewModel: set isOverlayLoading = true
        ViewModel->>Screen: show MifosProgressIndicatorOverlay
        ViewModel->>Repo: saveCollateral(data, quantity:String)
        Repo-->>ViewModel: Result
        ViewModel->>ViewModel: set isOverlayLoading = false
        ViewModel->>Screen: show ShowStatusDialog
    else Validation fails
        Validator-->>ViewModel: Invalid(errors)
        ViewModel->>Screen: set quantityError / show field errors
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • biplab1
  • revanthkumarJ
  • TheKalpeshPawar

Poem

🐰 Breadcrumbs hop where I may tread,
I count quantities as strings instead,
A spinner glows when saves are due,
Two buttons dance — back and submit too,
Hooray, the collateral path is new! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "client collateral button fix" is vague and does not accurately describe the substantial refactoring present in the changeset, which involves restructuring layouts, adding validation, and updating state management beyond a simple button fix. Revise the title to more accurately reflect the scope of changes, such as "Refactor ClientCollateralScreen layout and validation" or similar, to help reviewers understand the main architectural changes.
✅ Passed checks (1 passed)
Check name Status Explanation
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 docstrings

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

🤖 Fix all issues with AI agents
In
`@feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientCollateral/ClientCollateralScreen.kt`:
- Around line 122-130: When the user selects a different collateral in
MifosTextFieldDropdown the handler onOptionSelected currently only dispatches
ClientCollateralAction.OptionChanged(index) so derived totals remain stale;
update onOptionSelected to also trigger a recalculation by dispatching
ClientCollateralAction.OnQuantityChange(state.quantity) (or the equivalent
recalc action used in your reducer) immediately after OptionChanged so totals
and derived fields refresh on selection change.
- Around line 96-121: The root Column in ClientCollateralScreen is not receiving
the caller-provided modifier (it's only applied to the inner scroll Column),
which drops root-level size/semantics/test tags; move the incoming parameter
named modifier from the inner Column to the outer Column (the top-level Column
in ClientCollateralScreen) and replace the inner Column's usage with a plain
Modifier (e.g., Modifier.fillMaxWidth()...) so the outer container preserves
caller semantics while the inner scrollable Column uses its own local Modifier.

In
`@feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientCollateral/ClientCollateralViewModel.kt`:
- Around line 137-148: The code in ClientCollateralViewModel inside the is
ClientCollateralAction.OnQuantityChange branch currently calls
action.quantity.toInt() unguarded, which can throw NumberFormatException on
empty/invalid input; change the logic in mutableStateFlow.update to parse
action.quantity with toIntOrNull(), compute total and totalCollateral only when
the parsedInt is non-null, and otherwise set total and totalCollateral to 0.0
(and set quantityError appropriately); locate the update block handling
currentCollateral and replace the unguarded toInt() usage with a safe parse
(e.g., parsedQty) and conditional calculations using currentCollateral.basePrice
and currentCollateral.pctToBase.

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

🤖 Fix all issues with AI agents
In
`@feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientCollateral/ClientCollateralScreen.kt`:
- Around line 203-208: Add an isEnabled boolean to ClientCollateralState
(computed in ClientCollateralViewModel) derived from your validation rules
(e.g., quantityError == null and any other field-level errors are null) so the
view knows when submission is allowed; update the state calculation inside
ClientCollateralViewModel (where other derived fields are set) to set isEnabled
accordingly; then wire that field into ClientCollateralScreen by passing
state.isEnabled to MifosTwoButtonRow (so the submit button is disabled when
isEnabled is false) while keeping the existing onSecondBtnClick = {
onAction(ClientCollateralAction.OnSave) } handler.

@therajanmaurya therajanmaurya merged commit f40d2fb into openMF:development Jan 27, 2026
3 checks passed
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.

2 participants