Skip to content

[Shipping labels] Refund request UI #14170

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

Merged
merged 25 commits into from
Jun 12, 2025

Conversation

irfano
Copy link
Contributor

@irfano irfano commented Jun 10, 2025

Part of WOOMOB-370

Description

This adds the UI for the Refund request screen. The design slightly differs from the Figma file, as I aimed to maintain consistency with other screens, such as the Hazmat selection screen.

Warning

Network integration has not been implemented yet. Tapping the Refund label will result in infinite loading, which is expected at this stage.

Steps to reproduce

  1. Open the Orders screen.
  2. Select an order that includes a purchased shipment.
  3. Tap the "Request refund" button.
  4. Tap the "Refund label" button

The tests that have been performed

Steps above

Images/gif

  • 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.

irfano added 15 commits June 11, 2025 01:01
This commit introduces the `WooShippingLabelRefundViewModel` to manage the logic and state for the shipping label refund screen.
This commit introduces the `WooShippingLabelRefundFragment` which will be used to display the refund screen for shipping labels.
This commit updates the `LoadingScreen` in the split shipment feature. It replaces the Material `CircularProgressIndicator` with the Material3 version and wraps the `CircularProgressIndicator` with a `Surface` to ensure the background is white.
This commit modifies the `StartRefundRequest` event to include the `orderId` and the selected `shipment` data. This information is necessary for initiating the refund process for a specific shipping label.
This commit adds the navigation flow from the `WooShippingLabelCreationFragment` to the `WooShippingLabelRefundRequestFragment`.

When a refund is requested for a shipment, the app will now navigate to the refund request screen, passing the `orderId` and `shipment` details.
This commit updates the `GetShipments` class to include `refundableAmount` and `purchaseDate` when mapping a `ShippingLabelDTO` to a `Shipment`.
Instead of just getting its status, fetch the full `ShippingLabelModel`.
This change modifies the `ObserveShippingLabelStatus` use case to include the `refundableAmount` in its emitted result.
@irfano irfano added this to the 22.6 milestone Jun 10, 2025
@irfano irfano added feature: shipping labels Related to creating, ordering, or printing shipping labels. Task (new) labels Jun 10, 2025
@dangermattic
Copy link
Collaborator

dangermattic commented Jun 10, 2025

3 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ Class WooShippingLabelRefundViewModel is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ This PR is assigned to the milestone 22.6. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jun 10, 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 Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commitd86e726
Direct Downloadwoocommerce-wear-prototype-build-pr14170-d86e726.apk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I intentionally haven’t added any tests for this view model, as it doesn’t contain any meaningful logic. Let me know if you think we should still add them.

Copy link
Member

Choose a reason for hiding this comment

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

I think that's fine for now, but once we handle the networking of the refund, I think having some unit tests for the success and failures won't hurt, WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added in network PR: #14171

Comment on lines +66 to +70
if (_viewState.value is ViewState.Loading) {
triggerEvent(ShowSnackbar(R.string.order_refunds_refund_in_progress))
} else {
triggerEvent(Exit)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic was copied from ShippingLabelRefundFragment.

Comment on lines +573 to +578
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
CircularProgressIndicator()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also updated split screen to fix the background color of the loading composable.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jun 10, 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 Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commitd86e726
Direct Downloadwoocommerce-prototype-build-pr14170-d86e726.apk

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2025

Codecov Report

Attention: Patch coverage is 17.80822% with 60 lines in your changes missing coverage. Please review.

Project coverage is 37.74%. Comparing base (fde2b35) to head (d86e726).
Report is 68 commits behind head on trunk.

Files with missing lines Patch % Lines
...nglabels/refund/WooShippingLabelRefundViewModel.kt 0.00% 37 Missing ⚠️
...hippinglabels/WooShippingLabelCreationViewModel.kt 20.83% 19 Missing ⚠️
...ndroid/ui/orders/wooshippinglabels/GetShipments.kt 0.00% 2 Missing ⚠️
...inglabels/networking/WooShippingLabelRepository.kt 0.00% 1 Missing ⚠️
...pinglabels/purchased/ObserveShippingLabelStatus.kt 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk   #14170   +/-   ##
=========================================
  Coverage     37.73%   37.74%           
- Complexity     8949     8952    +3     
=========================================
  Files          1954     1955    +1     
  Lines        109474   109520   +46     
  Branches      14357    14364    +7     
=========================================
+ Hits          41315    41334   +19     
- Misses        64400    64427   +27     
  Partials       3759     3759           

☔ 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 self-assigned this Jun 11, 2025
Copy link
Member

@hichamboushaba hichamboushaba left a comment

Choose a reason for hiding this comment

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

Nice work @irfano, code looks good :shipit:

@@ -166,6 +171,13 @@ class WooShippingLabelCreationFragment : BaseFragment(), BackPressListener {
)
}

private fun startRefundRequest(orderId: Long, shipment: ShipmentUIModel) {
Copy link
Member

Choose a reason for hiding this comment

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

np, I would use a verb like show or open here, calling it start makes it seem like this will start the refund right away.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, navigateToRefundRequest would be a better name. All navigation events were previously prefixed with Start... in WooShippingLabelCreationViewModel. I've also renamed them all to start with NavigateTo....

Copy link
Member

Choose a reason for hiding this comment

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

I think that's fine for now, but once we handle the networking of the refund, I think having some unit tests for the success and failures won't hurt, WDYT?

@irfano irfano enabled auto-merge June 12, 2025 10:04
@irfano irfano merged commit 9d928e9 into trunk Jun 12, 2025
17 checks passed
@irfano irfano deleted the issue/WOOMOB-370-shipping-label-refund-UI branch June 12, 2025 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: shipping labels Related to creating, ordering, or printing shipping labels. Task (new) unit-tests-exemption
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants