Skip to content

Conversation

@hichamboushaba
Copy link
Member

@hichamboushaba hichamboushaba commented Oct 27, 2025

WOOMOB-1469

Description

Since Hicham did most of the work, I'm opening this PR to have at least some sort of Customer filter ready until we create new UI for the Bookings with multi-select option.

Test Steps

  1. Open the bookings tab
  2. Go to All tab
  3. Tap on Filters
  4. Select Customer
  5. Pick a customer
  6. Tap Show bookings
  7. Confirm the list was filtered

Images/gif

Screen_recording_20251105_134834.mp4
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@dangermattic
Copy link
Collaborator

dangermattic commented Oct 27, 2025

2 Warnings
⚠️ Class BookingCustomerFilterViewModel is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class CustomerListSelectionViewModel is missing tests, but unit-tests-exemption label was set to ignore this.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 27, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App NameWooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit1cd15fb
Direct Downloadwoocommerce-wear-prototype-build-pr14834-1cd15fb.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 27, 2025

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit1cd15fb
Direct Downloadwoocommerce-prototype-build-pr14834-1cd15fb.apk

@codecov-commenter
Copy link

codecov-commenter commented Oct 27, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.26%. Comparing base (00a1930) to head (1cd15fb).
⚠️ Report is 122 commits behind head on trunk.

Files with missing lines Patch % Lines
.../filter/customer/BookingCustomerFilterViewModel.kt 0.00% 12 Missing ⚠️
...kings/filter/customer/BookingCustomerFilterPage.kt 0.00% 9 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #14834      +/-   ##
============================================
- Coverage     38.27%   38.26%   -0.01%     
  Complexity    10117    10117              
============================================
  Files          2140     2142       +2     
  Lines        121101   121124      +23     
  Branches      16599    16603       +4     
============================================
+ Hits          46346    46347       +1     
- Misses        70046    70067      +21     
- Partials       4709     4710       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hichamboushaba hichamboushaba force-pushed the issue/WOOMOB-1469-bookings-customer-filter branch from fde7bb4 to 27c1262 Compare October 29, 2025 17:41
@hichamboushaba hichamboushaba force-pushed the issue/WOOMOB-1469-bookings-customer-filter branch from 27c1262 to 8a548c9 Compare October 29, 2025 18:24
@AdamGrzybkowski AdamGrzybkowski force-pushed the issue/WOOMOB-1469-bookings-customer-filter branch from 8a548c9 to 42df91a Compare November 5, 2025 09:57
@AdamGrzybkowski AdamGrzybkowski added this to the 23.7 milestone Nov 5, 2025
@AdamGrzybkowski AdamGrzybkowski changed the title [CIAB] Customer Filter approach (for discussion) [WOOMOB-1469] Customer Filter approach Nov 5, 2025
@AdamGrzybkowski AdamGrzybkowski changed the title [WOOMOB-1469] Customer Filter approach [WOOMOB-1469] Booking Customer Filter Nov 5, 2025
@AdamGrzybkowski AdamGrzybkowski marked this pull request as ready for review November 5, 2025 12:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the customer selection functionality to be reusable and implements a customer filter for bookings. The changes rename components from order-specific names to generic customer selection names and extract the exit logic to enable different behaviors (navigation vs. callbacks).

Key Changes:

  • Renamed OrderCustomerListScreen to CustomerListSelectionScreen for broader reusability
  • Made CustomerListSelectionViewModel open and extracted exitWithCustomer method to support customization
  • Implemented booking customer filter using the refactored customer selection components

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
strings.xml Shortened string resource from bookings_filter_customer_name to bookings_filter_customer
OrderCustomerListFragment.kt Updated to use renamed CustomerListSelectionScreen
CustomerListSelectionViewModel.kt Made class open and extracted exitWithCustomer method for customization
CustomerListSelectionScreen.kt Renamed composable and added showToolbar parameter for flexible UI
CustomerListDialogFragment.kt Updated to use renamed CustomerListSelectionScreen
BookingCustomerFilterViewModel.kt New ViewModel extending CustomerListSelectionViewModel with callback-based exit
BookingCustomerFilterPage.kt New composable page for booking customer filter
BookingFilterListUiState.kt Updated to use new string resource and added missing trailing comma
BookingFilterListScreen.kt Implemented customer filter page with customer selection logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 134 to 140
state.onUpdateFilterOption(
BookingsFilterOption.Customer(
customerId = customer.customerId ?: 0L,
customerName = "${customer.firstName} ${customer.lastName}".trim()
.ifBlank { customer.email }.orEmpty()
)
)
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Using a fallback of 0L for a null customerId could lead to incorrect filtering behavior if 0 is a valid customer ID in the system. Consider handling the null case explicitly by either preventing selection when customerId is null, or documenting that 0 represents 'no customer'.

Suggested change
state.onUpdateFilterOption(
BookingsFilterOption.Customer(
customerId = customer.customerId ?: 0L,
customerName = "${customer.firstName} ${customer.lastName}".trim()
.ifBlank { customer.email }.orEmpty()
)
)
customer.customerId?.let { id ->
state.onUpdateFilterOption(
BookingsFilterOption.Customer(
customerId = id,
customerName = "${customer.firstName} ${customer.lastName}".trim()
.ifBlank { customer.email }.orEmpty()
)
)
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

@AdamGrzybkowski, I think this is a good suggestion. We can commit Copilot’s code suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes and no, although technically that's possible because the model has a nullable ID, when you look at the code, that should never happen. I will commit it since it won't hurt us.

@irfano irfano self-assigned this Nov 5, 2025
@AdamGrzybkowski AdamGrzybkowski self-assigned this Nov 6, 2025
Copy link
Contributor

@irfano irfano left a comment

Choose a reason for hiding this comment

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

LGTM! We can add additional features, such as multiple selection, in a separate PR.

@AdamGrzybkowski AdamGrzybkowski merged commit 99ed8b3 into trunk Nov 6, 2025
18 checks passed
@AdamGrzybkowski AdamGrzybkowski deleted the issue/WOOMOB-1469-bookings-customer-filter branch November 6, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants