vtex / vtex.js

VTEX SDK for JavaScript
MIT License
120 stars 52 forks source link

CHK-846: Trigger attachmentUpdated event on sendAttachment method #77

Closed lucasecdb closed 2 years ago

lucasecdb commented 3 years ago

What is the purpose of this pull request?

Triggers a new event attachmentUpdated.vtex when an attachment is updated with the sendAttachment method

What problem is this solving?

This will enable us to listen for events on specific updates to attachments, which will be useful for us to implement the update on the address form UI when the invoice address is updated for example.

How should this be manually tested?

First, you need to run this repository with yarn grunt, then run vcs.checkout-ui with yarn grunt --link=vtex.js.

After that, you should be able to paste the following in your browser's devtools console:

$(window).on('attachmentUpdated.vtex', (_, attachmentId, orderForm) => {
  console.log({ attachmentId, orderForm })
})

And then interect with checkout as you would. You will be able to see the above log for every action that updates one of the attachments.

Screenshots or example usage

Types of changes