-
Notifications
You must be signed in to change notification settings - Fork 60
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 sort products issue #241
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -11,15 +11,14 @@ | |||||||
app.element('#product-filter').value = urlParams.get('sort'); | ||||||||
} | ||||||||
|
||||||||
|
||||||||
// Sort Products | ||||||||
app.on('change', '#product-filter', event => { | ||||||||
let url = new URL(window.location.href); | ||||||||
url.searchParams.set('sort', event.currentTarget.value); | ||||||||
window.history.pushState({}, '', url); | ||||||||
productsList.sortBy = event.currentTarget.value; | ||||||||
app.on('change','#product-filter', async event =>{ | ||||||||
window.history.replaceState(null, null, salla.helpers.addParamToUrl('sort',event.currentTarget.value)); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ Codacy found a critical Error Prone issue: You have a misspelled word: salla on Identifier The issue with the code is that the identifier "salla" is misspelled. It should be "Salla" instead. To fix this, you need to change "salla.helpers.addParamToUrl" to "Salla.helpers.addParamToUrl" in the code.
Suggested change
This comment was generated by an experimental AI tool. |
||||||||
app.element('salla-products-list').sortBy=event.currentTarget.value; | ||||||||
await app.element('salla-products-list').reload(); | ||||||||
Check failure on line 18 in src/assets/js/products.js Codacy Production / Codacy Static Code Analysissrc/assets/js/products.js#L18
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ Codacy found a critical Error Prone issue: Async functions are not supported yet on Node 4.0.0. The issue with the code is that it uses the To fix this issue, you can either declare the function as Here's the updated code: // Set Sort
if (urlParams.has('sort')) {
app.element('#product-filter').value = urlParams.get('sort');
}
// Sort Products
app.on('change','#product-filter', event =>{
window.history.replaceState(null, null, salla.helpers.addParamToUrl('sort',event.currentTarget.value));
app.element('salla-products-list').sortBy=event.currentTarget.value;
app.element('salla-products-list').reload()
.then(() => {
app.element('salla-products-list').setAttribute('filters', `{"sort": "${event.currentTarget.value}"}`);
});
});
salla.event.once('salla-products-list::products.fetched', res=>{
res.title && (app.element('#page-main-title').innerHTML = res.title);
});
this.initiateMobileMenu(); Note: This code assumes that This comment was generated by an experimental AI tool. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ Codacy found a critical Error Prone issue: You have a misspelled word: salla on String
Suggested change
Issue description: The code has a misspelled word "salla" in the string. It should be corrected to "salla-products-list". This comment was generated by an experimental AI tool. |
||||||||
app.element('salla-products-list').setAttribute('filters', `{"sort": "${event.currentTarget.value}"}`) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ Codacy found a critical Error Prone issue: You have a misspelled word: salla on String The code you provided has a misspelled word in the string. The correct spelling should be "sala" instead of "salla". To fix it, you need to update the code to use the correct spelling. Here's the corrected code:
Suggested change
Please note that I have replaced "salla" with "sala" in the code. This comment was generated by an experimental AI tool. |
||||||||
}); | ||||||||
|
||||||||
salla.event.once('salla-products-list::products.fetched', res=>{ | ||||||||
res.title && (app.element('#page-main-title').innerHTML = res.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.
❌ Codacy found a critical Error Prone issue: Async functions are not supported yet on Node 4.0.0.
The issue with the code is that it uses an async function, which is not supported in Node 4.0.0. To fix this, you can use a regular function instead of an async function. Here's the updated code:
Note: This code suggestion assumes that the
reload()
method returns a promise. If it doesn't, you may need to modify the code accordingly.This comment was generated by an experimental AI tool.