index.coffee 589 B

12345678910111213141516171819202122232425
  1. # app/components/Domain/CartWidget/index.coffee
  2. module.exports =
  3. name: 'cart-widget'
  4. props:
  5. items:
  6. type: Array
  7. default: -> []
  8. computed:
  9. itemsCount: ->
  10. @items.reduce ((total, item) -> total + (item.quantity or 1)), 0
  11. totalPrice: ->
  12. @items.reduce ((total, item) -> total + (item.price * (item.quantity or 1))), 0
  13. methods:
  14. goToCart: ->
  15. @$emit 'go-to-cart'
  16. updateCart: (items) ->
  17. @$emit 'update-cart', items
  18. render: (new Function '_ctx', '_cache', globalThis.renderFns['app/components/Domain/CartWidget/index.pug'])()