This commit is contained in:
2025-12-01 12:04:05 +03:30
parent e644606195
commit 6a6c8ce91a
2 changed files with 6 additions and 2 deletions
@@ -22,7 +22,7 @@ export class CartController {
@ApiResponse({ status: 200, description: 'Cart retrieved successfully' })
@ApiResponse({ status: 404, description: 'Cart not found' })
async findOne(@UserId() userId: string, @RestId() restaurantId: string) {
return this.cartService.findOne(userId, restaurantId);
return this.cartService.getOrCreateCart(userId, restaurantId);
}
@Post('items/:foodId/increment')
+5 -1
View File
@@ -65,7 +65,11 @@ export class CartService {
* Find cart by user and restaurant
*/
async findOne(userId: string, restaurantId: string): Promise<Cart> {
return this.getOrCreateCart(userId, restaurantId);
const cart = await this.getCartByRestaurant(userId, restaurantId);
if (!cart) {
throw new NotFoundException('Cart not found');
}
return cart;
}
/**