-
Notifications
You must be signed in to change notification settings - Fork 5
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
chore(add-item): permit insert flags when is the same product #187
Changes from all commits
d9726b9
04c7164
4e7a239
19c67ba
f985839
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default (item, newItem) => { | ||
// check flags | ||
const itemFlags = item.flags | ||
const newItemFlags = newItem.flags | ||
if (!itemFlags && !newItemFlags) { | ||
return true | ||
} else if (!itemFlags && newItemFlags || (itemFlags && !newItemFlags)) { | ||
return false | ||
} else { | ||
return itemFlags.every(flag => newItemFlags.includes(flag)) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { randomObjectId } from '@ecomplus/utils' | ||
import checkFlags from '../lib/check-flags' | ||
import fixItemQuantity from './../lib/fix-item-quantity' | ||
import fixItemFinalPrice from './../lib/fix-item-final-price' | ||
import fixSubtotal from './../lib/fix-subtotal' | ||
|
@@ -38,6 +39,8 @@ export default ({ data, save }, emitter, [newItem, canSave = true]) => { | |
return null | ||
} | ||
|
||
const check | ||
|
||
Comment on lines
+42
to
+43
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. 😐 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. 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. isso é um erro de sintaxe, não compila 🙃 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. estava com outro instalado 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. É, sei de onde brotou isso nao, devo ter copiado errado. Testei no meu local, mas nao conseguia subir por nao ter permissão, então copiei e coloquei direto no github 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. Foi mal |
||
let fixedItem | ||
if (!newItem.kit_product) { | ||
for (let i = 0; i < data.items.length; i++) { | ||
|
@@ -46,7 +49,8 @@ export default ({ data, save }, emitter, [newItem, canSave = true]) => { | |
!item.kit_product && | ||
item.product_id === newItem.product_id && | ||
item.variation_id === newItem.variation_id && | ||
(!item.customizations || !item.customizations.length) | ||
(!item.customizations || !item.customizations.length) && | ||
checkFlags(item, newItem) | ||
) { | ||
item.quantity += newItem.quantity | ||
if (newItem.price) { | ||
|
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.
Dá pra passar, mas (FYI) isso não vai funcionar se
itemFlags
for um array vazio ou se tiver menos flags que o do novo itemThere 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.
E cagou indentação aqui, o que me leva a crer que não tá usando o linter 😞 , nem testando...