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

fix: coupon code invalid error message #1009

Conversation

bartoszherba
Copy link
Collaborator

@bartoszherba bartoszherba commented May 17, 2022

Description

  • rework coupon code component to handle GraphQL errors

Related Issue

#957

Motivation and Context

How Has This Been Tested?

  • add the product to the cart
  • open the cart
  • try to apply invalid coupon -> observe there are no errors in the console and the error message is verbose
  • try to apply valid coupon -> observe that coupon was applied
  • try to remove coupon -> observe the coupon was applied

Screenshots (if appropriate):

Screenshot 2022-05-17 at 11 31 45

Types of changes

  • [ x] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@bartoszherba bartoszherba force-pushed the M2-559-coupon-code-input-box-should-show-error-message-when-an-invalid-coupon-code-is-entered branch from e053f14 to c7ee3b4 Compare May 17, 2022 09:34

error.value.applyCoupon = null;
if (errors) {
[error.value.applyCoupon] = errors;
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
[error.value.applyCoupon] = errors;
error.value.applyCoupon = errors;

Not sure if my suggestion is correct. Can't wrap my head around whether this is detructuring?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because I want to get the first element. Apply coupon is not an array and I pretty much doubt that there will be more than one error in the same time..

Copy link
Contributor

@sethidden sethidden left a comment

Choose a reason for hiding this comment

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

Left some comments

- rework coupon code component to handle GraphQL errors
M2-559
@bartoszherba bartoszherba force-pushed the M2-559-coupon-code-input-box-should-show-error-message-when-an-invalid-coupon-code-is-entered branch from c7ee3b4 to e3ab45e Compare May 17, 2022 10:43
@bartoszherba bartoszherba requested a review from sethidden May 17, 2022 10:43
@bartoszherba bartoszherba merged commit da3543f into develop May 17, 2022
@bartoszherba bartoszherba deleted the M2-559-coupon-code-input-box-should-show-error-message-when-an-invalid-coupon-code-is-entered branch May 17, 2022 10:58
@Frodigo Frodigo added this to the 1.0.0-rc.8 milestone May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants