1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6656],{58099:function(t,e,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard/draft-order/add",function(){return r(57418)}])},57418:function(t,e,r){"use strict";r.r(e),r.d(e,{default:function(){return add}});var d=r(85893),s=r(25079),a=r(70426),i=r(86886),o=r(22703),n=r(83771),c=r(66630),u=r(796),l=r(89397),h=r(87771),p=r(30080),f=r(66338),Z=r(37224),D=r(71141),O=r(8502),y=r(73596),v=r(81110);let CreateDraftOrderScreen=class CreateDraftOrderScreen extends y.u{async componentDidMount(){super.componentDidMount(),D.Z.updateBreadCrumbs([{text:s.Z.draftOrder.title,path:"/dashboard/order"},{text:s.Z.draftOrder.title}]),await this.getData(),this.setState({isLoading:!1})}constructor(t){super(t),this.getData=async()=>{let{draftOrders:t}=this.props;if(this.id&&(null==t?void 0:t.length)>0){let e=null==t?void 0:t.find(t=>t.key===parseInt(this.id)),{selectedProducts:r,orderData:d,choiceCustomer:s}=e;this.setState({selectedProducts:r,choiceCustomer:s,createdAt:new Date(null==d?void 0:d.createdAt)},this.updateMoney)}},this.genOrderData=async()=>{var t;let{totalMoney:e,selectedProducts:r,choiceCustomer:d,vat:s,createdAt:a}=this.state,i=this.inputNote.value,o=u.Z.convertNumber(this.surcharge||0);e=u.Z.convertNumber(e),this.paid=u.Z.convertNumber(this.paid||0);let n=(this.discount||0)/(this.totalProductMoney||1)*100;return{orderData:{id:(null===(t=this.props.params)||void 0===t?void 0:t.id)||null,type:this.type,money:e,paid:this.paid,status:this.status,oldStatus:status,moneyDiscount:n,vat:s,note:i,surcharge:o,createdAt:!this.isCopyAdd&&this.id?a:new Date},selectedProducts:r=null==r?void 0:r.map(t=>{let e=this.isImport?t.buyPrice:t.sellPrice;return t.discount=u.Z.convertNumber((e-t.price)/e*100||0),t.type=this.type,t}),choiceCustomer:d}},this.onClickDeleteDraft=()=>{v.Z.show(s.Z.draftOrder.cancel,s.Z.draftOrder.cancelConfirm,()=>{let{draftOrders:t=[]}=this.props;t=t.filter(t=>t.key!==parseInt(this.id)),this.updateDrafts(t),this.props.router.back()})},this.onPressSaveDraft=async()=>{o.Z.show();try{if(this.state.selectedProducts.length<1)return n.Z.error("",s.Z.order.invalidProduct);let{orderData:t,selectedProducts:e,choiceCustomer:r}=await this.genOrderData(),{draftOrders:d=[]}=this.props;d=this.id?d.map(d=>(d.key===parseInt(this.id)&&(d={...d,orderData:t,selectedProducts:e,choiceCustomer:r}),d)):[...d,{key:Date.now(),orderData:t,selectedProducts:e,choiceCustomer:r}],this.updateDrafts(d),n.Z.success("",s.Z.saved),O.Z.updateCartList([]),this.props.router.back()}catch(t){u.Z.log("ERROR",t)}o.Z.hide()},this.updateDrafts=t=>{localStorage.setItem(l.Z.DRAFT_ORDERS,JSON.stringify(t)),O.Z.updateDraftOrders(t)},this.renderHeader=()=>(0,d.jsx)(i.ZP,{container:!0,children:(0,d.jsxs)(i.ZP,{item:!0,container:!0,sx:{justifyContent:"flex-end"},children:[this.id&&(0,d.jsx)(Z.Z,{text:s.Z.draftOrder.cancel,icon:(0,d.jsx)(p.lTq,{size:20,color:"white"}),onClick:this.onClickDeleteDraft,color:"red","data-testid":"cancel-draft-button"}),(0,d.jsx)(Z.Z,{text:s.Z.saveDraft,icon:(0,d.jsx)(h.gg_,{size:16,color:"white"}),onClick:this.onPressSaveDraft,"data-testid":"save-draft-button"})]})}),this.title=s.Z.add+" "+s.Z.draftOrder.title}};var m=(0,f.$j)(t=>({productOrderUpdated:t.productReducer.productOrderUpdated,productOrderDeleted:t.productReducer.productOrderDeleted,productOrderAdd:t.productReducer.productOrderAdd,listCartItem:t.homeReducer.listCartItem,draftOrders:t.homeReducer.draftOrders}))((0,c.Z)(CreateDraftOrderScreen)),add=()=>(0,d.jsx)(m,{type:a.default.ORDER_TYPE.SALE,title:s.Z.add+" "+s.Z.draftOrder.title})}},function(t){t.O(0,[633,3739,2461,3059,8373,4047,1202,9044,2708,3748,9774,2888,179],function(){return t(t.s=58099)}),_N_E=t.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.