"implement product CRUD API endpoints and frontend integration"

This commit is contained in:
louiscklaw
2025-06-15 02:47:25 +08:00
parent 48e90bca1b
commit f53cf9d932
30 changed files with 623 additions and 342 deletions

View File

@@ -1,5 +1,7 @@
// src/app/services/product.service.ts
//
// REQ0182 frontend product details
//
// PURPOSE:
// - Service for handling ProductItem Record
//
@@ -65,11 +67,19 @@ type UpdateProduct = {
};
async function listProducts(): Promise<ProductItem[]> {
return prisma.productItem.findMany();
return prisma.productItem.findMany({
include: {
reviews: true,
},
});
}
async function getProduct(productId: string): Promise<ProductItem | null> {
return prisma.productItem.findUnique({ where: { id: productId } });
return prisma.productItem.findUnique({
where: { id: productId },
include: { reviews: true },
//
});
}
async function createProduct(createForm: CreateProduct) {