-
Notifications
You must be signed in to change notification settings - Fork 20
Update gtin value #88
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
Update gtin value #88
Conversation
|
Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖 Please select which version do you want to release:
And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.
|
|
Beep boop 🤖 I noticed you didn't make any changes at the
In order to keep track, I'll create an issue if you decide now is not a good time
|
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.
Pull Request Overview
This PR fixes GTIN value handling by conditionally skipping formatting when the gtinValue configuration is set to 'itemId'. The change prevents unnecessary padding of item IDs that should remain in their original format.
- Adds conditional logic to skip GTIN formatting for itemId values
- Updates changelog to document the fix
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| react/Product.js | Implements conditional GTIN formatting logic based on gtinValue type |
| CHANGELOG.md | Documents the fix for GTIN formatting when value is itemId |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
react/Product.js
Outdated
| const gtin = | ||
| rawGTIN != null | ||
| ? gtinValue === 'itemId' | ||
| ? rawGTIN // don't format itemId | ||
| : formatGTIN(rawGTIN) | ||
| : null |
Copilot
AI
Sep 24, 2025
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.
[nitpick] The nested ternary operator creates complex logic that's hard to read. Consider refactoring to use an if-else structure or extracting the logic into a helper function for better maintainability.
| const gtin = | |
| rawGTIN != null | |
| ? gtinValue === 'itemId' | |
| ? rawGTIN // don't format itemId | |
| : formatGTIN(rawGTIN) | |
| : null | |
| let gtin; | |
| if (rawGTIN != null) { | |
| if (gtinValue === 'itemId') { | |
| gtin = rawGTIN; // don't format itemId | |
| } else { | |
| gtin = formatGTIN(rawGTIN); | |
| } | |
| } else { | |
| gtin = null; | |
| } |
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.
@copilot can you simplify the nested if-else statements? for instance, by initializing the gtin value with null?
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.
Hi @albertm805 , first of all, thanks for the PR
Just did the tech code review
After reviewing the code, I have one question: Why do we need to store the GTIN in an unformatted state? Given that GTINs are strictly 8, 12, 13, or 14 characters long, wouldn't padding with zeros be enough? The example you provided shows a 5-character number - can you help me understand the reasoning behind this approach?
The reason why I am storing the GTIN in a raw state is because it can be any length value. If you consider that it shouldn't be done it can be changed. |
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.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
react/Product.js
Outdated
|
|
||
| let gtin = null | ||
|
|
||
| if (rawGTIN != null) { |
Copilot
AI
Sep 30, 2025
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.
Use strict equality (!==) instead of loose equality (!=) for null comparison to follow JavaScript best practices and avoid type coercion issues.
| if (rawGTIN != null) { | |
| if (rawGTIN !== null && rawGTIN !== undefined) { |
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.
@iago1501 is this something also an enhancement that will go with the PR or is there some other alternative code that you would like for me to include?
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.
This is an antomatic review made by copilot, it's suggesting an enhancement in your code, it's related to best practices in js:
Use strict equality (!==) instead of loose equality (!=) for null comparison to follow JavaScript best practices and avoid type coercion issues.
It would be great if you could commit this suggestion in the PR since you are using explicit null comparison
|
Hi @albertm805 , regarding the GTIN value,
Regarding the GTIN value, I understand that it can technically have any length, but perhaps it would be a good idea to follow what’s recommended in the documentation. If it specifies that GTIN should contain only 8, 12, 13, or 14 characters, I think it might be best to stick to those standards, even if that means adding leading zeros where necessary. |
552dfe1 to
9fb1b8c
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.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
iago1501
left a comment
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.
Just some semantical fixes
|
Your PR has been merged! App is being published. 🚀 After the publishing process has been completed (check #vtex-io-releases) and doing A/B tests with the new version, you can deploy your release by running:
After that your app will be updated on all accounts. For more information on the deployment process check the docs. 📖 |
What problem is this solving?
Removes formatting from skuId if the value from the admin is
itemIdHow should this be manually tested?
This can be tested here
Screenshots or example usage:
