This commit is contained in:
2025-11-23 01:07:49 +03:30
parent d9dde39a20
commit cc28b78596
5 changed files with 82 additions and 37 deletions
@@ -3,6 +3,7 @@ import { CartService } from '../providers/cart.service';
import { AddItemToCartDto } from '../dto/add-item.dto';
import { UpdateItemQuantityDto } from '../dto/update-item.dto';
import { ApplyCouponDto } from '../dto/apply-coupon.dto';
import { SetAddressDto } from '../dto/set-address.dto';
import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth, ApiBody, ApiParam } from '@nestjs/swagger';
import { AuthGuard } from '../../auth/guards/auth.guard';
import { UserId } from 'src/common/decorators/user-id.decorator';
@@ -73,4 +74,14 @@ export class CartController {
async removeCoupon(@UserId() userId: string, @RestId() restaurantId: string) {
return this.cartService.removeCoupon(userId, restaurantId);
}
@Patch('address')
@ApiOperation({ summary: 'Set address for cart' })
@ApiBody({ type: SetAddressDto })
@ApiResponse({ status: 200, description: 'Address set successfully' })
@ApiResponse({ status: 400, description: 'Bad request (e.g., address does not belong to user)' })
@ApiResponse({ status: 404, description: 'Address not found' })
async setAddress(@UserId() userId: string, @RestId() restaurantId: string, @Body() setAddressDto: SetAddressDto) {
return this.cartService.setAddress(userId, restaurantId, setAddressDto);
}
}