"use strict";(self.webpackChunkNexoPOS_4x=self.webpackChunkNexoPOS_4x||[]).push([[5022],{5022:(s,e,o)=>{o.r(e),o.d(e,{default:()=>u});var t=o(6386),n=o(8603);o(9671);const r={name:"ns-pos-coupons-popup",data:function(){return{orderSubscriber:null,hasLoaded:!1,order:null,coupons:[]}},mounted:function(){var s=this;this.popupCloser(),this.orderSubscriber=POS.order.subscribe((function(e){s.order=e})),this.loadCoupons()},destroyed:function(){this.orderSubscriber.unsubscribe()},methods:{__:o(7389).__,popupCloser:n.Z,popupResolver:t.Z,closePopup:function(){this.popupResolver(!1)},loadCoupons:function(){var s=this;this.hasLoaded=!1,nsHttpClient.get("/api/nexopos/v4/customers/".concat(this.order.customer_id,"/coupons")).subscribe((function(e){s.hasLoaded=!0,s.coupons=e}))}}};const u=(0,o(1900).Z)(r,(function(){var s=this,e=s.$createElement,o=s._self._c||e;return o("div",{staticClass:"shadow-lg bg-surface-tertiary w-95vw md:w-3/5-screen lg:w-2/5-screen"},[o("div",{staticClass:"border-b border-surface-secondary p-2 flex justify-between items-center"},[o("h3",{staticClass:"font-bold"},[s._v(s._s(s.__("Coupons")))]),s._v(" "),o("div",[o("ns-close-button",{on:{click:function(e){return s.closePopup()}}})],1)]),s._v(" "),o("div",{staticClass:"p-2"},[s.hasLoaded?s._e():o("div",{staticClass:"p-4"},[o("ns-spinner")],1),s._v(" "),s.hasLoaded?o("ul",[s._l(s.coupons,(function(e){return o("li",{key:e.id,staticClass:"p-2 cursor-pointer flex justify-between bg-gray-100 hover:bg-blue-200"},[o("span",[s._v(s._s(e.name))]),s._v(" "),o("span",[o("button",{staticClass:"rounded-full px-3 py-1"},[s._v(s._s(s.__("Use")))])])])})),s._v(" "),0===s.coupons.length&&s.hasLoaded?o("li",{staticClass:"py-3 text-center"},[s._v(s._s(s.__("No coupon available for this customer")))]):s._e()],2):s._e()])])}),[],!1,null,null,null).exports}}]);