import{a as U}from"./chunk-IJK7ICES.js";import{c as h,f,i as m,s as q,t as G,x as N}from"./chunk-CGR7IOZB.js";import{a as j}from"./chunk-6753ERK4.js";import"./chunk-YN2DAHZU.js";import{Ba as t,Ca as i,Fd as L,Ga as S,Ha as v,Hd as B,Id as I,Ja as d,Jb as E,K as a,Ka as c,Kd as R,L as s,Sa as b,Ta as n,Va as O,ab as w,ba as u,ca as g,fb as D,ha as C,ma as x,md as F,oc as k,pc as T,qa as _,qd as M,sb as V,vb as y}from"./chunk-7SK34GC7.js";import"./chunk-JKOY2XUY.js";var A=()=>[];function H(l,P){l&1&&S(0)}function z(l,P){if(l&1){let e=v();t(0,"c-modal",5)(1,"c-modal-header")(2,"h5",6),n(3),i(),t(4,"button",7),d("click",function(){a(e);let r=c();return s(r.toggleLiveDemo())}),i()(),t(5,"c-modal-body")(6,"c-col",8)(7,"div",9)(8,"select",10),d("change",function(r){a(e);let p=c();return s(p.selectedStatus(r))}),t(9,"option",11),n(10,"--select update--"),i(),t(11,"option",12),n(12,"Pending"),i(),t(13,"option",13),n(14,"Washing"),i(),t(15,"option",14),n(16,"Drying"),i(),t(17,"option",15),n(18,"Completed"),i()(),t(19,"label",16),n(20,"Update Status "),i()()()(),t(21,"c-modal-footer")(22,"button",17),d("click",function(){a(e);let r=c();return s(r.toggleLiveDemo())}),n(23," Close "),i(),t(24,"button",18),d("click",function(){a(e);let r=c();return s(r.updateOrder())}),n(25,"Update"),i()()()}if(l&2){let e=c();_("visible",e.liveDemoVisible),u(3),O("Order #",e.selectedOrder.order_num,""),u(4),_("cFormFloating",!0)}}var re=(()=>{class l{constructor(e,o){this.apiService=e,this.router=o,this.orderList=[],this.loading=!1,this.actions=[{label:"Edit",action:"edit",color:"warning",key:"id"},{label:"Delete",action:"delete",color:"danger",key:"id"},{label:"Update",action:"other",color:"secondary",key:"id"}],this.selectedOrder={},this.order=new f({order_id:new m(""),status:new m("",[h.required])}),this.filter=new f({table:new m("store_orders"),key:new m("status"),value:new m("",[h.required])}),this.liveDemoVisible=!1}loadOrders(){this.apiService.getStoreOrders().subscribe({next:e=>{this.orderList=e.data,this.loading=!1},error:e=>{console.error(e)}})}ngOnInit(){this.loadOrders()}toggleLiveDemo(){this.liveDemoVisible=!this.liveDemoVisible}update(e){this.selectedOrder=e,console.log(this.selectedOrder),this.order.patchValue({order_id:this.selectedOrder.id}),this.liveDemoVisible=!0}handleLiveDemoChange(e){this.liveDemoVisible=e}selectedStatus(e){let o=e.target;this.order.patchValue({status:o.value})}updateOrder(){this.loading=!0,console.log(this.order.value),this.apiService.updateOrder(this.order.value).subscribe({next:e=>{this.loading=!1,console.log(e),alert(e.message),this.liveDemoVisible=!1,this.loadOrders()},error:e=>{}})}static{this.\u0275fac=function(o){return new(o||l)(g(j),g(E))}}static{this.\u0275cmp=C({type:l,selectors:[["app-store-orders"]],decls:8,vars:5,consts:[["liveDemo",""],[1,""],[1,"d-flex","justify-content-between"],[3,"otherEvent","data","exclude","actions"],[4,"ngTemplateOutlet"],["id","liveDemoModal",3,"visible"],["cModalTitle",""],["cButtonClose","",3,"click"],["md",""],[3,"cFormFloating"],["id","","required","",1,"form-control",3,"change"],["value",""],["value","Pending"],["value","Washing"],["value","Drying"],["value","Completed"],["cLabel","","for","floatingInputGrid"],["cButton","","color","secondary",3,"click"],["cButton","","color","success",1,"text-white",3,"click"]],template:function(o,r){if(o&1){let p=v();t(0,"div",1)(1,"div",2)(2,"h3"),n(3,"Store Orders list"),i()(),t(4,"app-table",3),d("otherEvent",function(W){return a(p),s(r.update(W))}),i(),x(5,H,1,0,"ng-container",4)(6,z,26,3,"ng-template",null,0,D),i()}if(o&2){let p=b(7);u(4),_("data",r.orderList)("exclude",w(4,A))("actions",r.actions),u(),_("ngTemplateOutlet",p)}},dependencies:[U,L,R,I,B,T,k,V,M,F,N,q,G,y],encapsulation:2})}}return l})();export{re as StoreOrdersComponent};
