-
Notifications
You must be signed in to change notification settings - Fork 676
Feature/implemented filter loan accounts screen #2602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Feature/implemented filter loan accounts screen #2602
Conversation
📝 WalkthroughWalkthroughAdds 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
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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 makingFilterBottomSheetprivate.This composable appears to be used only within this screen file. Making it
privatewould 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(
...rc/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt
Outdated
Show resolved
Hide resolved
...commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsViewModel.kt
Show resolved
Hide resolved
...rc/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt
Outdated
Show resolved
Hide resolved
...rc/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt
Outdated
Show resolved
Hide resolved
...rc/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt
Outdated
Show resolved
Hide resolved
...rc/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt
Outdated
Show resolved
Hide resolved
...rc/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt
Outdated
Show resolved
Hide resolved
...commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsViewModel.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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).
...rc/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt
Show resolved
Hide resolved
...commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsViewModel.kt
Outdated
Show resolved
Hide resolved
...rc/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
eb70b97 to
9df4098
Compare
58af90e to
7e606ba
Compare
...commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsViewModel.kt
Show resolved
Hide resolved
7e606ba to
0259834
Compare
There was a problem hiding this 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 | 🟠 MajorFilter state becomes inconsistent after refresh/search.
When
getLoanAccountssucceeds, it resets bothloanAccountsandunfilteredLoanAccountsto the full result set, butselectedStatusis not cleared. This means the filter chips will still appear selected in the UI while the list shows unfiltered data.Either clear
selectedStatushere, 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 usingSet<LoanStatusFilter>instead ofList<LoanStatusFilter>.
selectedStatusrepresents a collection of unique selections.Setis semantically more appropriate, guarantees uniqueness without relying on the toggle guard, and makes the intent clearer. The+/-/inoperators work identically onSet.Diff across affected locations
// In ClientLoanAccountsState: - val selectedStatus: List<LoanStatusFilter> = emptyList(), + val selectedStatus: Set<LoanStatusFilter> = emptySet(), // In clearFilters(): - selectedStatus = emptyList(), + selectedStatus = emptySet(),
0259834 to
8b1be9e
Compare
|
@piyushs-05 Please run |
a6b83db to
d0bf28d
Compare
|
|
@piyushs-05 Have you updated the red dot on filter if any of the options are selected? If yes, then update the screen recording. |
|
@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 ? |



Fixes - Jira-#646
Please Add Screenshots If there are any UI changes.
before_filter.mp4
after_filter.mp4
Please make sure these boxes are checked before submitting your pull request - thanks!
Run the static analysis check
./gradlew checkorci-prepush.shto make sure you didn't break anythingIf you have multiple commits please combine them into one commit by squashing them.
Summary by CodeRabbit