Skip to content

[OMS] Add cancel button and modal @W-18998059#2775

Merged
sf-emmyzhang merged 11 commits intofeature/order-management-pluginfrom
feature/cancel-order-btn
Jul 15, 2025
Merged

[OMS] Add cancel button and modal @W-18998059#2775
sf-emmyzhang merged 11 commits intofeature/order-management-pluginfrom
feature/cancel-order-btn

Conversation

@sf-emmyzhang
Copy link
Contributor

@sf-emmyzhang sf-emmyzhang commented Jul 10, 2025

Description

Added a "Cancel order" button next to the Order Details heading that opens a "Request Cancellation" modal dialog.

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • Added "Cancel order" button to order details page header (authenticated user only, guest will be covered after order details for guest is completed)
  • Created reusable CancelOrderModal component
  • Test coverage and labels
Screenshot 2025-07-11 at 10 53 44 AM Screenshot 2025-07-11 at 10 53 51 AM

How to Test-Drive This PR

Deployed to https://cc-sharks-dev-emmy-test.mobify-storefront-staging.com

  • Place an order as an authenticated buyer
  • Go to order history and click on order details for the order
  • Cancel order button should be seen in the top right of the order details page
  • Clicking the cancel order button should open a modal

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@cc-prodsec
Copy link
Collaborator

cc-prodsec commented Jul 10, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@sf-emmyzhang sf-emmyzhang force-pushed the feature/cancel-order-btn branch from 1814eb7 to 0f886ec Compare July 11, 2025 15:09
@sf-emmyzhang sf-emmyzhang changed the title Add cancel button and modal @W-18998059 [OMS] Add cancel button and modal @W-18998059 Jul 11, 2025
@sf-emmyzhang sf-emmyzhang marked this pull request as ready for review July 11, 2025 17:33
@sf-emmyzhang sf-emmyzhang requested a review from a team as a code owner July 11, 2025 17:33
@sf-emmyzhang sf-emmyzhang added the ready for review PR is ready to be reviewed label Jul 11, 2025
@sf-deepali-bharmal sf-deepali-bharmal force-pushed the feature/order-management-plugin branch from ccc0c81 to 5c5a5e7 Compare July 15, 2025 17:24
…der-btn

Signed-off-by: sf-emmyzhang <emmyzhang@salesforce.com>
Copy link
Contributor

@vmarta vmarta left a comment

Choose a reason for hiding this comment

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

Just some minor comments. Other than that, PR is good. Button works and opens up the modal.

- Show Automatic Bonus Products on Cart Page [#2704](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2704)
- Support Standard Products [2697](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2697)
- Fix passwordless race conditions in form submission [#2758](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2758)
- Add cancel button and modal @W-18998059 [#2775](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/2775)
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 our ticket number here? The changelog is meant for public audience.

Comment on lines +29 to +30
order = null,
onRequestCancellation = null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
order = null,
onRequestCancellation = null,
order,
onRequestCancellation,

There's a difference betweennull vs undefined. I think of null as something intentionally passed in.

But in this case, I don't think it's necessary to add null or undefined. Your component propTypes already specifies which props are required and optional.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've also seen noops set as default for some modals, not sure what difference that makes because the values always seem to be populated (required)

...props
}) => {
const handleRequestCancellation = () => {
if (onRequestCancellation) {
Copy link
Contributor

@kzheng-sfdc kzheng-sfdc Jul 15, 2025

Choose a reason for hiding this comment

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

Should onRequestCancellation allowed to be falsy at all? That means we don't do anything, which sounds wrong?

/**
* Order object for cancellation
*/
order: PropTypes.object,
Copy link
Contributor

Choose a reason for hiding this comment

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

required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, as we'll eventually need order information to be displayed in the cancel order modal

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add .isRequired to it, then?

id="account_order_detail.title.order_details"
/>
</Heading>
<Button variant="link" size="sm" onClick={onCancelModalOpen}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Not all orders are cancellable, right? How do we make sure this doesn't show up at all times?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I haven't added that logic bit yet. I recently learned that SOM has a field called QuantityAvailableToCancel on each orderItemSummary. I will incorporate that in the next iteration, and add a todo comment to address that here if that works?

Copy link
Contributor

Choose a reason for hiding this comment

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

Other than quantity (why would quantity matter when canceling an order?), I'd imagine the order status also matters? I am good with doing it in the next iteration. Thanks.

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 question, I'll follow up on that

if (!onRequestCancellation) {
console.error('Cancel order modal: onRequestCancellation is required')
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can safely remove this check now that it's marked as isRequired.

@sf-emmyzhang sf-emmyzhang merged commit d789bcf into feature/order-management-plugin Jul 15, 2025
36 checks passed
@sf-emmyzhang sf-emmyzhang deleted the feature/cancel-order-btn branch July 15, 2025 22:29
sf-deepali-bharmal added a commit that referenced this pull request Jul 21, 2025
* add button and modal

* Initial empty commit for order-management-plugin

* separate modal component; changelog

* unit tests

* labels

* remove redundancy

* chakra?

* update changelog

* mark cancellation props as required

---------

Signed-off-by: sf-emmyzhang <emmyzhang@salesforce.com>
Co-authored-by: sf-deepali-bharmal <deepali.bharmal@salesforce.com>
sf-deepali-bharmal added a commit that referenced this pull request Jul 21, 2025
* add button and modal

* Initial empty commit for order-management-plugin

* separate modal component; changelog

* unit tests

* labels

* remove redundancy

* chakra?

* update changelog

* mark cancellation props as required

---------

Signed-off-by: sf-emmyzhang <emmyzhang@salesforce.com>
Co-authored-by: sf-deepali-bharmal <deepali.bharmal@salesforce.com>
sf-deepali-bharmal added a commit that referenced this pull request Aug 19, 2025
* add button and modal

* Initial empty commit for order-management-plugin

* separate modal component; changelog

* unit tests

* labels

* remove redundancy

* chakra?

* update changelog

* mark cancellation props as required

---------

Signed-off-by: sf-emmyzhang <emmyzhang@salesforce.com>
Co-authored-by: sf-deepali-bharmal <deepali.bharmal@salesforce.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants