Skip to content
This repository was archived by the owner on Jul 20, 2026. It is now read-only.

Commit f1eca6e

Browse files
committed
WIP
1 parent 33cc08c commit f1eca6e

5 files changed

Lines changed: 42 additions & 4 deletions

File tree

backend/src/routes/product.routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { productController } from '../container';
99
const router = Router();
1010

1111
const idValidation = [param('id').isInt().withMessage('Invalid ID')];
12-
const showHiddenValidation = [query('showHidden').isBoolean().withMessage('showHidden should be a boolean')];
12+
const showHiddenValidation = [query('showHidden').optional().isBoolean().withMessage('showHidden should be a boolean')];
1313

1414
//.custom((value) => value === null || typeof value === 'number').withMessage('Supplier ID must be a number or null')
1515
const productValidation = {

frontend/src/app/pages/admin/admin.component.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

frontend/src/app/pages/shop/shop.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export class ShopComponent implements OnInit {
4141
this.productService.getProducts().subscribe({
4242
next: (res) => {
4343
if (res.success) {
44-
const mappedProducts = (res.data || []).map(p => this.mapProduct(p));
44+
const mappedProducts = (res.data || [])
45+
.filter(p => !p.hidden)
46+
.map(p => this.mapProduct(p));
4547
this.allProducts.set(mappedProducts);
4648
}
4749
},

frontend/src/app/services/order.service.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,11 @@ export class OrderService {
3232
{ headers: this.authHeaders }
3333
);
3434
}
35+
36+
getInvoices(): Observable<{ success: boolean; message: string; data: any[] }> {
37+
return this.http.get<{ success: boolean; message: string; data: any[] }>(
38+
`${this.apiUrl}/invoices`,
39+
{ headers: this.authHeaders }
40+
);
41+
}
3542
}

frontend/src/app/services/product.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export class ProductService {
2222
return this.http.get<{ success: boolean; message: string; data: any[] }>(`${this.apiUrl}/products`);
2323
}
2424

25+
getAllProducts(): Observable<{ success: boolean; message: string; data: any[] }> {
26+
return this.http.get<{ success: boolean; message: string; data: any[] }>(`${this.apiUrl}/products?showHidden=true`);
27+
}
28+
2529
getProductDetail(id: number): Observable<{ success: boolean; message: string; data: any }> {
2630
return this.http.get<{ success: boolean; message: string; data: any }>(`${this.apiUrl}/products/${id}/detail`);
2731
}

0 commit comments

Comments
 (0)