Skip to content
This repository was archived by the owner on Jul 20, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/src/routes/product.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { productController } from '../container';
const router = Router();

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

//.custom((value) => value === null || typeof value === 'number').withMessage('Supplier ID must be a number or null')
const productValidation = {
Expand Down
29 changes: 27 additions & 2 deletions frontend/src/app/pages/admin/admin.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class AdminComponent implements OnInit {
}

loadProducts() {
this.productService.getProducts().subscribe({
this.productService.getAllProducts().subscribe({
next: (res) => {
this.products.set((res.data || []).map((p: any) => ({
id: p.id,
Expand Down Expand Up @@ -141,7 +141,32 @@ export class AdminComponent implements OnInit {


loadOrders() {
this.orders.set([]);
this.orderService.getInvoices().subscribe({
next: (res) => {
this.orders.set((res.data || []).map((i: any) => ({
id: String(i.id),
createdAt: i.createdAt,
customer: {
firstName: i.billingAddress?.firstName || '',
lastName: i.billingAddress?.lastName || '',
email: i.billingAddress?.email || '',
address: i.billingAddress?.address || '',
city: i.billingAddress?.city || '',
zip: i.billingAddress?.zip || ''
},
items: (i.items || []).map((it: any) => ({
type: 'product' as const,
name: it.name,
quantity: it.quantity,
unitPrice: parseFloat(it.price),
customizationSummary: it.customizationSummary
})),
total: parseFloat(i.amount),
status: this.mapBackendStatusToFrontend(i.status)
})));
},
error: (err) => console.error('Failed to load orders:', err)
});
}

toggleOrder(id: string) {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/app/pages/shop/shop.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export class ShopComponent implements OnInit {
this.productService.getProducts().subscribe({
next: (res) => {
if (res.success) {
const mappedProducts = (res.data || []).map(p => this.mapProduct(p));
const mappedProducts = (res.data || [])
.filter(p => !p.hidden)
.map(p => this.mapProduct(p));
this.allProducts.set(mappedProducts);
}
},
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/app/services/order.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ export class OrderService {
{ headers: this.authHeaders }
);
}

getInvoices(): Observable<{ success: boolean; message: string; data: any[] }> {
return this.http.get<{ success: boolean; message: string; data: any[] }>(
`${this.apiUrl}/invoices`,
{ headers: this.authHeaders }
);
}
}
4 changes: 4 additions & 0 deletions frontend/src/app/services/product.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export class ProductService {
return this.http.get<{ success: boolean; message: string; data: any[] }>(`${this.apiUrl}/products`);
}

getAllProducts(): Observable<{ success: boolean; message: string; data: any[] }> {
return this.http.get<{ success: boolean; message: string; data: any[] }>(`${this.apiUrl}/products?showHidden=true`);
}

getProductDetail(id: number): Observable<{ success: boolean; message: string; data: any }> {
return this.http.get<{ success: boolean; message: string; data: any }>(`${this.apiUrl}/products/${id}/detail`);
}
Expand Down
Loading