Skip to content

Conversation

@piyushs-05
Copy link

@piyushs-05 piyushs-05 commented Feb 5, 2026

Fixes - Jira-#646

Please Add Screenshots If there are any UI changes.

Before
before_filter.mp4
After
after_filter.mp4

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 bottom-sheet filter for loan accounts with multi-select status options (Active, Pending, Waiting for Disbursal, Closed, Overpaid).
    • Users can Apply or Clear status filters to update the loan list; filter selections are retained while the sheet is open.
    • Added localized labels for the filter UI and adjusted spacing for a more consistent layout.

@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Adds a modal FilterBottomSheet UI to filter client loan accounts by status, wires open/close and Clear/Apply actions into ClientLoanAccountsScreen, extends ClientLoanAccountsViewModel with unfilteredLoanAccounts, selectedStatus, LoanStatusFilter enum, toggle/clear filter actions, and new string resources for status labels.

Changes

Cohort / File(s) Summary
Filter UI
feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt
Adds FilterBottomSheet composable and ModalBottomSheetState, renders sheet when state.isFilterDialogOpen, header with Clear/Apply actions, status list with checkboxes bound to selectedStatus, and replaces an 8.dp spacer with DesignToken.padding.small.
ViewModel & State
feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsViewModel.kt
Adds unfilteredLoanAccounts and selectedStatus to state; new LoanStatusFilter enum; new actions HandleFilterClick and ClearFilters; implements toggle/clear filter logic and status helper extensions; updates getLoanAccounts flow to set unfiltered data.
Localization
feature/client/src/commonMain/composeResources/values/strings.xml
Adds strings for filter UI: feature_client_filters, feature_client_account_status, and status labels feature_client_status_active, feature_client_status_pending, feature_client_status_waiting, feature_client_status_closed, feature_client_status_overpaid.

Sequence Diagram

sequenceDiagram
    actor User
    participant Screen as ClientLoanAccountsScreen
    participant ViewModel as ClientLoanAccountsViewModel
    participant State as UIState

    User->>Screen: Tap filter icon
    Screen->>State: set isFilterDialogOpen = true
    Screen->>User: show FilterBottomSheet

    User->>Screen: Toggle status checkbox
    Screen->>ViewModel: HandleFilterClick(status)
    ViewModel->>ViewModel: toggle status in selectedStatus
    ViewModel->>ViewModel: filter loanAccounts from unfilteredLoanAccounts
    ViewModel->>State: emit updated selectedStatus & loanAccounts
    State->>Screen: recompose list

    User->>Screen: Tap Apply
    Screen->>State: set isFilterDialogOpen = false

    User->>Screen: Tap Clear
    Screen->>ViewModel: ClearFilters
    ViewModel->>ViewModel: reset loanAccounts & clear selectedStatus
    ViewModel->>State: emit cleared state
    State->>Screen: recompose with all accounts
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • revanthkumarJ
  • biplab1
  • itsPronay

Poem

🐰
A sheet unfolds where statuses gleam,
I hop and tick boxes like in a dream.
Clear with a twitch, apply with a cheer,
Loans lined up tidy — hop, filters here! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
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.
✅ 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 'Feature/implemented filter loan accounts screen' accurately reflects the main change: implementing a filter feature for the loan accounts screen. It is clear, specific, and directly related to the primary functionality being added.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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: 2

🤖 Fix all issues with AI agents
In
`@feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt`:
- Around line 292-298: Rename the typo'd parameter handelFilterClick to
handleFilterClick in the FilterBottomSheet function signature and update all
uses inside that function to refer to handleFilterClick; then update every call
site that passes or references that parameter (e.g., where FilterBottomSheet is
invoked and any related lambdas in ClientListScreen) to use the corrected name
so the symbol matches across definitions and usages.

In
`@feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsViewModel.kt`:
- Around line 149-151: The inner variable `val status = loan.status` inside the
filter lambda in ClientLoanAccountsViewModel is shadowing the enclosing function
parameter `status: String`; rename the inner variable (e.g., to `loanStatus`)
and update all uses within the lambda (the filter condition and any comparisons)
so the lambda reads `val loanStatus = loan.status ?: return@filter false`
thereby avoiding shadowing and improving readability while preserving behavior.
🧹 Nitpick comments (2)
feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt (2)

305-311: Hardcoded strings should use string resources for localization.

The status types and UI labels ("Filters", "Account Status", "Clear", "Apply") are hardcoded. For i18n support, extract these to string resources similar to other strings in the file.

♻️ Suggested approach

Add string resources in the appropriate resources file:

// In strings file
feature_client_filter_title = "Filters"
feature_client_account_status = "Account Status"
feature_client_status_active = "Active"
feature_client_status_pending = "Pending Approval"
// etc.

Then use stringResource():

 Text(
-    text = "Filters",
+    text = stringResource(Res.string.feature_client_filter_title),
     style = MifosTypography.titleLargeEmphasized,
     color = MaterialTheme.colorScheme.primary,
 )

Also applies to: 323-327, 355-358


291-292: Consider making FilterBottomSheet private.

This composable appears to be used only within this screen file. Making it private would be consistent with other composables in this file (e.g., ClientsAccountHeader, ClientLoanAccountsDialog) and prevent unintended external usage.

♻️ Proposed fix
 `@OptIn`(ExperimentalMaterial3Api::class)
 `@Composable`
-fun FilterBottomSheet(
+private fun FilterBottomSheet(

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: 2

🤖 Fix all issues with AI agents
In
`@feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt`:
- Around line 335-353: Replace the hard-coded English contentDescription values
for the two Icon composables with localized string resources: change the Icon
using MifosIcons.Redo (inside the IconButton that calls clearFilters() and
onDismissRequest()) to use stringResource(R.string.clear) and change the Icon
using MifosIcons.Check (inside the IconButton that calls onDismissRequest()) to
use stringResource(R.string.apply); then add corresponding entries ("clear" and
"apply") to the platform strings.xml so accessibility labels are localized.

In
`@feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsViewModel.kt`:
- Around line 138-166: The filter currently compares localized display strings
in handleFilterClick (and similar logic around selectedStatus usage), so replace
the string-based selectedStatus with a Set of stable keys (e.g., a new
LoanStatusFilter enum/sealed class with values like ACTIVE, CLOSED,
PENDING_APPROVAL, WAITING_FOR_DISBURSAL, OVERPAID), update handleFilterClick to
toggle those enum values and filter unfilteredLoanAccounts by matching
loan.status boolean flags against the enum values (set loanAccounts =
filteredList), and update the UI to pass LoanStatusFilter values while rendering
labels via stringResource(...) so localization does not break filtering; also
apply the same enum-based replacements where selectedStatus is read/modified
elsewhere (the other occurrences mentioned).

Copy link
Collaborator

@itsPronay itsPronay left a comment

Choose a reason for hiding this comment

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

LGTM, Please get it approved by another team member and then request a merge

@piyushs-05 piyushs-05 force-pushed the feature/Implemented-filter-loan-accounts-screen branch from eb70b97 to 9df4098 Compare February 5, 2026 16:38
@piyushs-05 piyushs-05 force-pushed the feature/Implemented-filter-loan-accounts-screen branch 2 times, most recently from 58af90e to 7e606ba Compare February 5, 2026 17:29
@piyushs-05 piyushs-05 force-pushed the feature/Implemented-filter-loan-accounts-screen branch from 7e606ba to 0259834 Compare February 6, 2026 10:50
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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsViewModel.kt (1)

117-124: ⚠️ Potential issue | 🟠 Major

Filter state becomes inconsistent after refresh/search.

When getLoanAccounts succeeds, it resets both loanAccounts and unfilteredLoanAccounts to the full result set, but selectedStatus is not cleared. This means the filter chips will still appear selected in the UI while the list shows unfiltered data.

Either clear selectedStatus here, or re-apply the active filters to the new data.

Proposed fix (clear filters on reload)
                 mutableStateFlow.update {
                     it.copy(
                         loanAccounts = loanAccounts,
                         unfilteredLoanAccounts = loanAccounts,
+                        selectedStatus = emptyList(),
                         dialogState = null,
                         isLoading = false,
                     )
                 }
🧹 Nitpick comments (1)
feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsViewModel.kt (1)

138-168: Consider using Set<LoanStatusFilter> instead of List<LoanStatusFilter>.

selectedStatus represents a collection of unique selections. Set is semantically more appropriate, guarantees uniqueness without relying on the toggle guard, and makes the intent clearer. The + / - / in operators work identically on Set.

Diff across affected locations
 // In ClientLoanAccountsState:
-    val selectedStatus: List<LoanStatusFilter> = emptyList(),
+    val selectedStatus: Set<LoanStatusFilter> = emptySet(),

 // In clearFilters():
-                selectedStatus = emptyList(),
+                selectedStatus = emptySet(),

@piyushs-05 piyushs-05 force-pushed the feature/Implemented-filter-loan-accounts-screen branch from 0259834 to 8b1be9e Compare February 6, 2026 11:11
@biplab1
Copy link
Contributor

biplab1 commented Feb 6, 2026

@piyushs-05 Please run ./ci-prepush.sh to fix spotless error and push the updates.

@piyushs-05 piyushs-05 force-pushed the feature/Implemented-filter-loan-accounts-screen branch from a6b83db to d0bf28d Compare February 6, 2026 17:03
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 6, 2026

@biplab1
Copy link
Contributor

biplab1 commented Feb 6, 2026

@piyushs-05 Have you updated the red dot on filter if any of the options are selected? If yes, then update the screen recording.

@piyushs-05
Copy link
Author

@biplab1 not in this one sir . Just be sure i need to change the colour of filter icon if any of the filters is selected right ?

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.

4 participants