1import{a as ct}from"./chunk-IAMOTYSI.js";import"./chunk-TPZH5VFB.js";import{b as tt,c as et,d as it,f as nt,g as rt,i as ot,j as at,l as mt,m as lt,o as dt,p as st,q as pt}from"./chunk-IRVXRWZD.js";import{d as W}from"./chunk-OASEBQL4.js";import{b as Z}from"./chunk-H3ZOHFO7.js";import{c as Q,f as X,j as Y}from"./chunk-CIKJJUSN.js";import"./chunk-RRZRS5BZ.js";import"./chunk-LY7WOQZN.js";import"./chunk-DTV26CKL.js";import"./chunk-MS4AQ6UA.js";import{b as J,d as K}from"./chunk-N7NZ2FMU.js";import{f as G}from"./chunk-F2TSTV3I.js";import"./chunk-XRMXGMS4.js";import"./chunk-Q4V6AKYI.js";import"./chunk-T3PLPHIG.js";import"./chunk-2JW6ZMWV.js";import"./chunk-NIP74ZKI.js";import"./chunk-QNUNLKYK.js";import{a as w,r as q}from"./chunk-RE4JJFV5.js";import"./chunk-COEKBYWO.js";import"./chunk-E2K2LIS4.js";import"./chunk-KJKRX6VS.js";import"./chunk-2CRWMDGS.js";import"./chunk-4WMDX4SQ.js";import"./chunk-IQLKO45Z.js";import"./chunk-V6KBZVCY.js";import"./chunk-6FQQM4CE.js";import{a as V,i as U,j}from"./chunk-VTTO24NQ.js";import"./chunk-Y5VOXWTF.js";import{q as N}from"./chunk-YWHNFDXQ.js";import"./chunk-FCTHY2PU.js";import"./chunk-DPVJW3LI.js";import"./chunk-GW33KQPR.js";import{T as k,U as z}from"./chunk-TUEKBDZZ.js";import"./chunk-RLPOKPIS.js";import"./chunk-TPES7EAS.js";import{G as B,h as F,m as H}from"./chunk-QXJM3TTT.js";import{F as A,w as R,x as $}from"./chunk-TMOIAHHX.js";import{Fa as d,Ib as o,Kb as c,Rb as D,Sa as E,Sb as b,Tb as I,ab as f,bb as i,cb as r,db as x,ga as l,hb as s,ib as p,kb as L,mc as h,nc as O,o as S,oc as P,p as M,qb as T,sa as C,tb as _,za as v}from"./chunk-DJNWGYMM.js";import{ea as g,f as y}from"./chunk-VOZAGDK7.js";import"./chunk-E5QWB6YB.js";function ut(t,n){t&1&&(i(0,"th",18),o(1,"Order ID"),r())}function ft(t,n){if(t&1&&(i(0,"td",19)(1,"strong"),o(2),r()()),t&2){let e=n.$implicit;l(2),c("#",e.id==null?null:e.id.substring(0,8))}}function _t(t,n){t&1&&(i(0,"th",18),o(1,"Customer"),r())}function Ct(t,n){if(t&1&&(i(0,"td",19),o(1),r()),t&2){let e=n.$implicit;l(),c(" ",e.userId," ")}}function xt(t,n){t&1&&(i(0,"th",18),o(1,"Items"),r())}function ht(t,n){if(t&1&&(i(0,"td",19)(1,"div",20)(2,"mat-icon"),o(3,"shopping_bag"),r(),i(4,"span"),o(5),r()()()),t&2){let e=n.$implicit,a=_();l(5),c("",a.getTotalItems(e)," item(s)")}}function gt(t,n){t&1&&(i(0,"th",18),o(1,"Total"),r())}function St(t,n){if(t&1&&(i(0,"td",19)(1,"strong",21),o(2),r()()),t&2){let e=n.$implicit;l(2),c("$",e.total.toFixed(2))}}function Mt(t,n){t&1&&(i(0,"th",18),o(1,"Status"),r())}function Ot(t,n){if(t&1&&(i(0,"td",19)(1,"mat-chip-set")(2,"mat-chip",22),o(3),h(4,"uppercase"),r()()()),t&2){let e=n.$implicit,a=_();l(2),f("color",a.getStatusColor(e.status)),l(),c(" ",O(4,2,e.status)," ")}}function wt(t,n){t&1&&(i(0,"th",18),o(1,"Payment"),r())}function yt(t,n){if(t&1&&(i(0,"td",19)(1,"mat-chip-set")(2,"mat-chip",22),o(3),h(4,"uppercase"),r()()()),t&2){let e=n.$implicit,a=_();l(2),f("color",a.getPaymentStatusColor(e.paymentStatus)),l(),c(" ",O(4,2,e.paymentStatus)," ")}}function vt(t,n){t&1&&(i(0,"th",18),o(1,"Date"),r())}function Et(t,n){if(t&1&&(i(0,"td",19),o(1),h(2,"date"),r()),t&2){let e=n.$implicit;l(),c(" ",P(2,1,e.createdAt,"short")," ")}}function Lt(t,n){t&1&&(i(0,"th",18),o(1,"Actions"),r())}function Tt(t,n){if(t&1){let e=L();i(0,"td",19)(1,"mat-form-field",23)(2,"mat-label"),o(3,"Update Status"),r(),i(4,"mat-select",24),I("ngModelChange",function(m){let u=S(e).$implicit;return b(u.status,m)||(u.status=m),M(m)}),T("selectionChange",function(){let m=S(e).$implicit,u=_();return M(u.updateOrderStatus(m,m.status))}),i(5,"mat-option",25),o(6,"Pending"),r(),i(7,"mat-option",26),o(8,"Processing"),r(),i(9,"mat-option",27),o(10,"Completed"),r(),i(11,"mat-option",28),o(12,"Cancelled"),r()()()()}if(t&2){let e=n.$implicit;l(4),D("ngModel",e.status)}}function Dt(t,n){t&1&&x(0,"tr",29)}function bt(t,n){t&1&&x(0,"tr",30)}function It(t,n){if(t&1&&(i(0,"tr",31)(1,"td",32)(2,"mat-icon",33),o(3,"receipt_long"),r(),i(4,"div",34),o(5,"No orders yet"),r()()()),t&2){let e=_();l(),E("colspan",e.displayedColumns.length)}}var ne=(()=>{class t{cartService;notify;ngxLoader;orders=[];displayedColumns=["orderId","userId","items","total","status","paymentStatus","date","actions"];destroy$=new y;constructor(e,a,m){this.cartService=e,this.notify=a,this.ngxLoader=m}
1ngOnInit(){this.loadOrders()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}loadOrders(){this.ngxLoader.start(),this.cartService.getAllOrders().pipe(g(this.destroy$)).subscribe({next:e=>{this.orders=e.sort((a,m)=>{let u=a.createdAt?new Date(a.createdAt).getTime():0;return(m.createdAt?new Date(m.createdAt).getTime():0)-u}),this.ngxLoader.stop()},error:e=>{this.notify.openAlertModal(e.error?e.error:"'Failed to load orders'",w.ERROR),console.error(e),this.ngxLoader.stop()}})}updateOrderStatus(e,a){e.id&&(this.ngxLoader.start(),this.cartService.updateOrderStatus(e.id,a).pipe(g(this.destroy$)).subscribe({next:()=>{this.notify.openToaster("Order status updated successfully","success"),this.loadOrders()},error:m=>{this.notify.openAlertModal(m.error?m.error:"Failed to update order status",w.ERROR),console.error(m),this.ngxLoader.stop()}}))}getStatusColor(e){switch(e){case"completed":return"primary";case"processing":return"accent";case"cancelled":return"warn";default:return""}}getPaymentStatusColor(e){switch(e){case"paid":return"primary";case"failed":return"warn";default:return""}}getTotalItems(e){return e.items.reduce((a,m)=>a+m.quantity,0)}static \u0275fac=function(a){return new(a||t)(C(ct),C(q),C(W))};static \u0275cmp=v({type:t,selectors:[["app-order-list"]],decls:32,vars:3,consts:[[1,"page-layout","simple","fullwidth"],["title","Order Management","subtitle","View and manage customer orders"],[1,"content","order-list-container",2,"padding","24px"],[1,"table-container",2,"background","white","border-radius","8px","box-shadow","0 2px 4px rgba(0,0,0,0.1)","overflow","hidden"],["mat-table","",1,"orders-table",2,"width","100%",3,"dataSource"],["matColumnDef","orderId"],["mat-header-cell","",4,"matHeaderCellDef"],["mat-cell","",4,"matCellDef"],["matColumnDef","userId"],["matColumnDef","items"],["matColumnDef","total"],["matColumnDef","status"],["matColumnDef","paymentStatus"],["matColumnDef","date"],["matColumnDef","actions"],["mat-header-row","",4,"matHeaderRowDef"],["mat-row","",4,"matRowDef","matRowDefColumns"],["class","mat-row",4,"matNoDataRow"],["mat-header-cell",""],["mat-cell",""],[2,"display","flex","align-items","center","gap","8px"],[2,"font-size","16px"],["highlighted","",3,"color"],["appearance","outline",2,"width","150px"],[3,"ngModelChange","selectionChange","ngModel"],["value","pending"],["value","processing"],["value","completed"],["value","cancelled"],["mat-header-row",""],["mat-row",""],[1,"mat-row"],[1,"mat-cell",2,"text-align","center","padding","48px"],[2,"font-size","64px","width","64px","height","64px","color","#ccc"],[2,"margin-top","16px","color","#666"]],template:function(a,m){a&1&&(i(0,"div",0),x(1,"page-header",1),i(2,"div",2)(3,"div",3)(4,"table",4),s(5,5),d(6,ut,2,0,"th",6)(7,ft,3,1,"td",7),p(),s(8,8),d(9,_t,2,0,"th",6)(10,Ct,2,1,"td",7),p(),s(11,9),d(12,xt,2,0,"th",6)(13,ht,6,1,"td",7),p(),s(14,10),d(15,gt,2,0,"th",6)(16,St,3,1,"td",7),p(),s(17,11),d(18,Mt,2,0,"th",6)(19,Ot,5,4,"td",7),p(),s(20,12),d(21,wt,2,0,"th",6)(22,yt,5,4,"td",7),p(),s(23,13),d(24,vt,2,0,"th",6)(25,Et,3,4,"td",7),p(),s(26,14),d(27,Lt,2,0,"th",6)(28,Tt,13,1,"td",7),p(),d(29,Dt,1,0,"tr",15)(30,bt,1,0,"tr",16)(31,It,6,1,"tr",17),r()()()()),a&2&&(l(4),f("dataSource",m.orders),l(25),f("matHeaderRowDef",m.displayedColumns),l(),f("matRowDefColumns",m.displayedColumns))},dependencies:[A,B,F,H,N,z,k,pt,tt,it,at,nt,et,mt,rt,ot,lt,dt,st,Y,Q,X,K,U,V,J,G,j,Z,R,$],styles:[".order-list-container[_ngcontent-%COMP%]{max-width:1400px;margin:0 auto}.orders-table[_ngcontent-%COMP%] .mat-mdc-row[_ngcontent-%COMP%]{transition:background-color .2s}.orders-table[_ngcontent-%COMP%] .mat-mdc-row[_ngcontent-%COMP%]:hover{background-color:#f5f5f5}.orders-table[_ngcontent-%COMP%] .mat-mdc-header-cell[_ngcontent-%COMP%]{font-weight:600;color:#333}.orders-table[_ngcontent-%COMP%] .mat-mdc-cell[_ngcontent-%COMP%]{padding:16px 8px}mat-chip[_ngcontent-%COMP%]{font-size:11px;font-weight:600}mat-form-field[_ngcontent-%COMP%]{font-size:12px}"]})}return t})();export{ne as OrderListComponent};
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.