@@ -97,7 +97,7 @@ export class AdminComponent implements OnInit {
9797 }
9898
9999 loadProducts ( ) {
100- this . productService . getProducts ( ) . subscribe ( {
100+ this . productService . getAllProducts ( ) . subscribe ( {
101101 next : ( res ) => {
102102 this . products . set ( ( res . data || [ ] ) . map ( ( p : any ) => ( {
103103 id : p . id ,
@@ -141,7 +141,32 @@ export class AdminComponent implements OnInit {
141141
142142
143143 loadOrders ( ) {
144- this . orders . set ( [ ] ) ;
144+ this . orderService . getInvoices ( ) . subscribe ( {
145+ next : ( res ) => {
146+ this . orders . set ( ( res . data || [ ] ) . map ( ( i : any ) => ( {
147+ id : String ( i . id ) ,
148+ createdAt : i . createdAt ,
149+ customer : {
150+ firstName : i . billingAddress ?. firstName || '' ,
151+ lastName : i . billingAddress ?. lastName || '' ,
152+ email : i . billingAddress ?. email || '' ,
153+ address : i . billingAddress ?. address || '' ,
154+ city : i . billingAddress ?. city || '' ,
155+ zip : i . billingAddress ?. zip || ''
156+ } ,
157+ items : ( i . items || [ ] ) . map ( ( it : any ) => ( {
158+ type : 'product' as const ,
159+ name : it . name ,
160+ quantity : it . quantity ,
161+ unitPrice : parseFloat ( it . price ) ,
162+ customizationSummary : it . customizationSummary
163+ } ) ) ,
164+ total : parseFloat ( i . amount ) ,
165+ status : this . mapBackendStatusToFrontend ( i . status )
166+ } ) ) ) ;
167+ } ,
168+ error : ( err ) => console . error ( 'Failed to load orders:' , err )
169+ } ) ;
145170 }
146171
147172 toggleOrder ( id : string ) {
0 commit comments