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

[Shipping labels] Remotely validate edited address #15023

Merged
merged 6 commits into from
Jan 31, 2025

Conversation

rachelmcr
Copy link
Contributor

@rachelmcr rachelmcr commented Jan 30, 2025

Part of: #13781
⚠️ Based on #15020 ⚠️

Description

This adds remote validation to the address editing view in the Woo Shipping label flow.

When the "Validate & Save" button is tapped, it remotely validates the address and opens a sheet to confirm the address. This suggests the normalized address provided by the backend. (Note that we are matching the web behavior and displaying this view even if the entered and suggested addresses match.)

Changes

  • In WooShippingEditAddressView:
    • When the status is unverified tapping the primary button now calls the view model's remotelyValidateAddress() method (and shows a loading indicator while the request is in progress).
    • When the view model's normalizeAddressVM is set, it opens a sheet with the normalize address view.
  • In WooShippingEditAddressViewModel, we prepare the address to be validated with the current field values, call the remote action, and set normalizeAddressVM based on the response.
  • WooShippingNormalizeAddressViewModel is updated to include an ID (so it can be used as a SwiftUI sheet item) and its closure is now optional for convenience.

Notes:

  • We don't yet handle an error response from the validation endpoint. For now errors are logged to the console, but a later PR will add them to the UI.
  • The full "confirm address" flow isn't finished yet, so the address can't be confirmed after that sheet is opened. That will come in a later PR.

Testing information

  1. Ensure the latest production version of WooCommerce Shipping (Version 1.3.2) is installed, activated, and set up on your store.
  2. Create or open an order with at least one physical product and the processing status.
  3. Tap "Create Shipping Label" in order details.
  4. Open the "Shipment details" bottom sheet.
  5. Tap the "Ship from" origin address.
  6. Tap the edit (pencil) icon on one of the origin addresses.
  7. In the edit address sheet, update the name field.
  8. Tap "Validate & Save" and confirm the "Confirm Address" sheet opens with the entered and suggested (normalized) address.
  9. Tap "Cancel" to go back and enter a non-existent address.
  10. Tap "Validate & Save" and confirm the error from the remote endpoint is logged to the console, and the "Confirm Address" sheet does not open.

Screenshots

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-01-30.at.15.31.36.mp4

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

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 all devices (phone/tablet) and no regressions are added.

@rachelmcr rachelmcr added the feature: shipping labels Related to creating, ordering, or printing shipping labels. label Jan 30, 2025
@rachelmcr rachelmcr added this to the 21.6 milestone Jan 30, 2025
@rachelmcr rachelmcr requested a review from toupper January 30, 2025 15:32
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 30, 2025

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

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr15023-1f11137
Version21.5
Bundle IDcom.automattic.alpha.woocommerce
Commit1f11137
App Center BuildWooCommerce - Prototype Builds #12748
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Copy link
Contributor

@toupper toupper left a comment

Choose a reason for hiding this comment

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

LGTM! Just a minor non blocker comment 🚀 🚢 :shipit:

// MARK: Remote validation

/// Whether the address is being remotely validated.
@Published private(set) var isRemotelyValidating: Bool = false
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the comment, would the property be named isRemotelyValidated instead of validating?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this property is like an isLoading property, tracking when the remote validation is in progress (so we can show the loading indicator on the button). I'll update the comment to make that clearer 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, thanks for the clarification

@wpmobilebot wpmobilebot modified the milestones: 21.6, 21.7 Jan 31, 2025
@wpmobilebot
Copy link
Collaborator

Version 21.6 has now entered code-freeze, so the milestone of this PR has been updated to 21.7.

Base automatically changed from issue/13781-handle-local-changes to trunk January 31, 2025 13:52
@rachelmcr rachelmcr enabled auto-merge January 31, 2025 13:52
@rachelmcr rachelmcr merged commit b26dbdd into trunk Jan 31, 2025
14 checks passed
@rachelmcr rachelmcr deleted the issue/13781-remotely-validate-address branch January 31, 2025 13:52
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants