-
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
Conversation
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.
Não entendi, você quer adicionar flags no item que já existe?
É aquele caso do brinde? Se for na real não era pra você adicionar a flag no item que já existe, é pra ter a flag só no novo item mesmo (o brinde):
- item 0: 5 granolas, sem flag
- item 1: 1 granola, freebie
Do jeito que você tá fazendo aí mudaria o item 0, aí teria só um item com 6 granolas e todas freebie, não é isso? Aí não passaria no checkout...
Se for pro caso do mesmo produto sendo pago e como brinde, eu acho que você tem que editar é essa condição aqui shopping-cart/src/methods/add-item.js Lines 45 to 50 in d9726b9
|
É examente isso que queria fazer desde o início, achava que por ser mesmo id, ele atualizava e não inseria outro. |
src/lib/check-flags.js
Outdated
const newItemFlags = newItem.flags ? newItem.flags : false | ||
if (!itemFlags && !newItemFlags) { | ||
return true | ||
} else if (!itemFlags && newItemFlags || itemFlags && !newItemFlags) { |
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.
esses AND e OR aqui estão ambíguos, teria que ter um parênteses na segunda parte
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.
E o StandardJS te mostraria isso antes de mim inclusive..
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.
Ue, eu estou com isso instalado no meu vs code
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.
Tem que instalar as dependências (sempre) do repositório também
Fez isso?
Co-authored-by: Leonardo Matos <leomp120894@gmail.com>
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.
👍🏾
} else if (!itemFlags && newItemFlags || (itemFlags && !newItemFlags)) { | ||
return false | ||
} else { | ||
return itemFlags.every(flag => newItemFlags.includes(flag)) |
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 item
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.
E cagou indentação aqui, o que me leva a crer que não tá usando o linter 😞 , nem testando...
const check | ||
|
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.
😐
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.
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.
isso é um erro de sintaxe, não compila 🙃
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.
estava com outro instalado
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.
É, 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Foi mal
No description provided.