-
Notifications
You must be signed in to change notification settings - Fork 25
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
feat: add DiscountApplicationStrategyCard #154
Conversation
Hello and thank you for your contribution! Before we can merge your pull request, we ask that you create a changeset to describe your changes. This will help us manage versions and release notes. You can create a changeset by running |
327a8d2
to
e76c803
Compare
e76c803
to
01994a4
Compare
We have received a translation request but there is a question blocking translation work. Your help is needed. Please answer the following questions.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
I'm reluctant to call it DiscountAppStrategyCard, it might be worth calling it DiscountApplicationStrategyCard even though it's longer :/ let me know how you feel about that. It would be more inline with the name of the api field and avoids confusion.
|
||
expect(methodCard).not.toContainReactComponent(TextField, { | ||
label: 'Title', | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test that ensures the onChange function is called with the value of the choice selected?
|
||
## Usage and best practices | ||
|
||
- The discount code length only adjusts the default length of generated codes, and does not set a max length for the text input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this part of the readme is related to this card?
.changeset/gentle-windows-juggle.md
Outdated
'@shopify/discount-app-components': minor | ||
--- | ||
|
||
Add DiscountAppStrategyCard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add what it does here:
Add DiscountApplicationStrategyCard, which allows the user to select the discount application strategy, maximum or first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the comments, have updated each of them in the latest commits 🙏
12201a7
to
ee26d4a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Added a couple more comments. 😄
### Basic usage | ||
|
||
```jsx | ||
<DiscountAppStategyCard strategy="All" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be FIRST or MAXIMUM in the props. https://shopify.dev/docs/api/functions/reference/order-discounts/graphql/common-objects/discountapplicationstrategy :)
src/types.ts
Outdated
|
||
export enum DiscountApplicationStrategy { | ||
First = 'First', | ||
Maximum = 'Maximum', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These values should be capitalized as per the API values: https://shopify.dev/docs/api/functions/reference/order-discounts/graphql/common-objects/discountapplicationstrategy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch! updated
}, | ||
]} | ||
selected={[strategy.value]} | ||
onChange={handleChange} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last thing sorry :D should the value be represented by the ENUM here? Instead of a translated string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you're referring specifically to the selected
value, then I think it would be fine so long as the pattern in MethodCard is accurately representing the pattern we should value.
However, I do see that the choices
' values can and should be updated to the enum!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was referring to the value prop in the choices :) I guess my comment was at the wrong spot!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
What problem is this PR solving?
closes: https://github.com/Shopify/core-issues/issues/60529
Reviewers’ hat-rack 🎩
yarn storybook
DiscountAppStrategyCard
Before requesting reviews
Before you deploy