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

feat(feature): Implemented Client Filter functionality

Open techsavvy185 opened this issue 11 months ago • 1 comments

Fixes - Jira-MIFOSAC-517

WhatsApp Image 2025-12-07 at 17 51 04 (1) WhatsApp Image 2025-12-07 at 17 51 04 (2)

https://github.com/user-attachments/assets/c16224b7-8c9f-4b7d-b3d6-f2b004857aa1

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

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

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

Summary by CodeRabbit

  • New Features
    • Added a filter modal to the client list with Sort (Name, Account Number, External ID), Account Status, and Office selectors.
    • Toggle filter visibility from the actions bar; apply, clear, and combine multiple filters.
    • Client list now publishes available office names for filtering.
    • Sorting and filtering apply to both the visible list and paging results while preserving existing loading/error UIs.

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

techsavvy185 avatar Dec 07 '25 12:12 techsavvy185

Walkthrough

Adds a client-list filtering feature: UI for sort/status/office (FilterBottomSheet), ViewModel support for filter state and unfiltered data/flows, and platform updates to pass sort and onUpdateOffices into the list composable (Android implements sorting/office extraction; Desktop signature updated; iOS adds a stub).

Changes

Cohort / File(s) Change Summary
ViewModel - State & Actions
feature/client/src/commonMain/kotlin/.../ClientListViewModel.kt
Added unfilteredClients/unfilteredClientsFlow, new UI state fields (sort, selectedStatus, isFilterVisible, officeNames, selectedOffices), new actions (ToggleFilterVisibility, HandleFilterClick, HandleSortClick, OnUpdateOffice, ClearFilters), and logic to maintain/derive filtered clients and flows.
Shared UI - Filter & List Composables
feature/client/src/commonMain/kotlin/.../ClientListScreen.kt
Added FilterBottomSheet composable and sheet state wiring; added filter visibility toggle and callbacks; updated ClientListContentScreen, ClientActions, and LazyColumnForClientListApi signatures to accept sort: SortTypes? and onUpdateOffices: (List<String?>) -> Unit; integrated filter callbacks into screen.
Android Implementation - List Rendering & Sorting
feature/client/src/androidMain/kotlin/com/mifos/feature/client/clientsList/ClientListScreen.android.kt
Extended LazyColumnForClientListApi signature; on initial snapshot computes distinct office names and calls onUpdateOffices; added branch to render a sorted items path when sort is set (NAME/ACCOUNT_NUMBER/EXTERNAL_ID) while preserving original unsorted/paging append, loading, and error handling.
Desktop Implementation - Signature Update
feature/client/src/desktopMain/kotlin/com/mifos/feature/client/clientsList/ClientListScreen.desktop.kt
Updated LazyColumnForClientListApi signature to include sort and onUpdateOffices (no behavioral change).
iOS Implementation - Stub Added
feature/client/src/iosMain/kotlin/com/mifos/feature/client/clientsList/ClientListScreen.ios.kt
Added actual implementation stub for LazyColumnForClientListApi with new parameters (sort, onUpdateOffices); body is empty.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI as FilterBottomSheet
    participant Screen as ClientListScreen
    participant VM as ClientListViewModel
    participant Data as DataLayer

    User->>Screen: Open filter sheet (toggle)
    Screen->>VM: ToggleFilterVisibility
    VM-->>Screen: isFilterVisible updated

    User->>UI: Choose sort/status/offices -> Apply
    UI->>Screen: Dispatch HandleSortClick / HandleFilterClick
    Screen->>VM: Dispatch actions
    VM->>VM: update sort/selectedStatus/selectedOffices
    VM->>Data: derive filtered list & paging from unfilteredClients / unfilteredClientsFlow
    Data-->>VM: filtered results (list + PagingData)
    VM-->>Screen: Emit clients / clientsFlow (updated)
    Screen->>User: Re-rendered client list (sorted/filtered)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Pay extra attention to:
    • Consistency between unfilteredClients and unfilteredClientsFlow propagation and when each is updated.
    • Correctness of handleFilterClick / handleSortClick applying filters to both list and paging flow.
    • Android sorted vs unsorted rendering branches (keying, LaunchedEffect for image fetch, and append/loading handling).
    • Signature alignment and usage of new callbacks across Android, Desktop, and iOS stubs.

Poem

🐰 I hopped through lists both big and small,
I nudged a filter, sorted one and all.
Offices gathered, statuses set,
The client list dances—neat as a net.
Hooray! 🥕📋

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: implementing client filter functionality across multiple files (ViewModel, UI screens, filter sheet integration).
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ 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.

coderabbitai[bot] avatar Dec 07 '25 12:12 coderabbitai[bot]