Skip to content
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

[Woo POS][Cash & Receipts] Navigation via navigation component to the cash payment screen #13069

Conversation

kidinov
Copy link
Contributor

@kidinov kidinov commented Dec 4, 2024

Closes: #13063

Description

The PR moves mock of the cash payment state to a separate screen. The screen now opened using compose navigation

Testing information

  • More -> POS -> Add product -> Checkout
  • Click on take payment button
  • Notice a new screen is opened
  • Navigate back

The tests that have been performed

Above

Images/gif

12-05--14-46.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.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@kidinov kidinov marked this pull request as draft December 4, 2024 16:28
@dangermattic
Copy link
Collaborator

dangermattic commented Dec 4, 2024

5 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ Class WooPosCashPaymentRepository is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class WooPosCashPaymentState is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class WooPosCashPaymentUIEvent is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class WooPosCashPaymentViewModel is missing tests, but unit-tests-exemption label was set to ignore this.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 4, 2024

📲 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 Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commita2b4711
Direct Downloadwoocommerce-wear-prototype-build-pr13069-a2b4711.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 4, 2024

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

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commita2b4711
Direct Downloadwoocommerce-prototype-build-pr13069-a2b4711.apk

import com.woocommerce.android.ui.woopos.root.navigation.WooPosNavigationEvent

@Composable
fun WooPosCashPaymentScreen(onNavigationEvent: (WooPosNavigationEvent) -> Unit) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mock of the UI as we still have no design ready

val state: StateFlow<WooPosCashPaymentState> = _state

init {
viewModelScope.launch {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As there is no finilized design yet, I don't know the state needed, therefore not unit tests

@kidinov kidinov marked this pull request as ready for review December 5, 2024 13:47
@kidinov kidinov requested a review from AnirudhBhat December 5, 2024 13:47
Base automatically changed from 13004-woo-poscash-receipts-add-optional-take-payment-button-and-empty-state-for-cash to trunk December 6, 2024 08:04
…complition-call-from-the-mocked-cash-payment-screen

# Conflicts:
#	WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/totals/WooPosTotalsViewModel.kt
#	WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/totals/WooPosTotalsViewModelTest.kt
@kidinov kidinov added this to the 21.3 milestone Dec 9, 2024
@AnirudhBhat AnirudhBhat self-assigned this Dec 9, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 8.43373% with 76 lines in your changes missing coverage. Please review.

Project coverage is 40.44%. Comparing base (9731223) to head (a2b4711).
Report is 68 commits behind head on trunk.

Files with missing lines Patch % Lines
...i/woopos/cashpayment/WooPosCashPaymentViewModel.kt 0.00% 23 Missing ⚠️
.../woopos/cashpayment/WooPosCashPaymentNavigation.kt 0.00% 20 Missing ⚠️
.../woopos/cashpayment/WooPosCashPaymentRepository.kt 0.00% 9 Missing ⚠️
...id/ui/woopos/cashpayment/WooPosCashPaymentState.kt 0.00% 8 Missing ⚠️
...rce/android/ui/woopos/home/WooPosHomeNavigation.kt 0.00% 6 Missing ⚠️
.../ui/woopos/cashpayment/WooPosCashPaymentUIEvent.kt 0.00% 2 Missing ⚠️
...oid/ui/woopos/home/totals/WooPosTotalsViewModel.kt 60.00% 2 Missing ⚠️
...ui/woopos/root/navigation/WooPosNavigationEvent.kt 0.00% 2 Missing ⚠️
...os/root/navigation/WooPosNavigationEventHandler.kt 0.00% 2 Missing ⚠️
...oid/ui/woopos/home/totals/WooPosTotalsViewState.kt 80.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #13069      +/-   ##
============================================
- Coverage     40.49%   40.44%   -0.05%     
+ Complexity     6188     6187       -1     
============================================
  Files          1287     1292       +5     
  Lines         74207    74270      +63     
  Branches      10156    10159       +3     
============================================
- Hits          30050    30039      -11     
- Misses        41549    41623      +74     
  Partials       2608     2608              

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

Copy link
Contributor

@AnirudhBhat AnirudhBhat left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @kidinov. The navigation works as expected. I've left few nitpicks which are not blocking for the merge.

I also observed an issue with navigation where successive clicks on "take cash payment" button opens the cash payment screen twice.

cash_payment_issue.mp4

val enteredAmount: String,
val changeDue: String,
val total: String,
val canBeOrderBeCompleted: Boolean,
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ nitpick: canBeOrderBeCompleted naming sounds confusing. Should it be canOrderBeCompleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. That's val is gone in the following PR where the actual state based on the design apepared

private const val ROUTE = "cash_payment/{orderId}"

fun NavController.navigateToCashPaymentScreen(orderId: Long) {
navigate("cash_payment/$orderId")
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Using ROUTE.replace("{orderId}", orderId.toString()) would improve maintainability, avoiding mismatches between the navigation declaration and usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

) {
Column(
modifier = Modifier
.width(540.dp)
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ Do we need to hardcode this width here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope. But as I mentioned this is a mock. The actual UI is implemented in the following PR


@WooPosPreview
@Composable
fun WooPosTotalsPaymentCashScreenScreen() {
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ Should the name be WooPosTotalsPaymentCashScreenPreview?

Also, since it's actually previewing WooPosCashPaymentScreen. What do you think about calling it WooPosCashPaymentScreenPreview instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Fixed here f3412b4

viewModelScope.launch {
val order = repository.getOrderById(orderId)!!
_state.value = WooPosCashPaymentState.Collecting(
enteredAmount = "",
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: enteredAmount is initialised as an empty string, and changeDue as BigDecimal.ZERO, which might not align with realistic scenarios. We could consider initialising these values based on prior state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kidinov kidinov merged commit c891053 into trunk Dec 11, 2024
15 checks passed
@kidinov kidinov deleted the 13063-woo-poscash-receipts-implement-order-complition-call-from-the-mocked-cash-payment-screen branch December 11, 2024 09:23
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.

[Woo POS][Cash & Receipts] Navigation to the cash payment screen via compose navigation
5 participants