import { Controller, Get, Patch, Body, UseGuards, Req, UseInterceptors, ClassSerializerInterceptor, } from "@nestjs/common"; import { UsersService } from "./users.service"; import { JwtAuthGuard } from "../auth/guards/jwt-auth.guard"; import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth } from "@nestjs/swagger"; import { UpdateUserDto } from "./dto/update-user.dto"; import { UpdateBillingDto } from "./dto/update-billing.dto"; import { RequestWithUser } from "../auth/auth.types"; @ApiTags("users") @Controller("me") @UseGuards(JwtAuthGuard) @ApiBearerAuth() @UseInterceptors(ClassSerializerInterceptor) export class UsersController { constructor(private usersService: UsersService) {} @Get() @ApiOperation({ summary: "Get current user profile" }) @ApiResponse({ status: 200, description: "User profile retrieved successfully" }) @ApiResponse({ status: 401, description: "Unauthorized" }) async getProfile(@Req() req: RequestWithUser) { return this.usersService.findById(req.user.userId); } @Get("summary") @ApiOperation({ summary: "Get user dashboard summary" }) @ApiResponse({ status: 200, description: "User summary retrieved successfully" }) @ApiResponse({ status: 401, description: "Unauthorized" }) async getSummary(@Req() req: RequestWithUser) { return this.usersService.getUserSummary(req.user.userId); } @Patch() @ApiOperation({ summary: "Update user profile" }) @ApiResponse({ status: 200, description: "Profile updated successfully" }) @ApiResponse({ status: 400, description: "Invalid input data" }) @ApiResponse({ status: 401, description: "Unauthorized" }) async updateProfile(@Req() req: RequestWithUser, @Body() updateData: UpdateUserDto) { return this.usersService.update(req.user.userId, updateData); } @Patch("billing") @ApiOperation({ summary: "Update billing information" }) @ApiResponse({ status: 200, description: "Billing information updated successfully" }) @ApiResponse({ status: 400, description: "Invalid input data" }) @ApiResponse({ status: 401, description: "Unauthorized" }) updateBilling(@Req() _req: RequestWithUser, @Body() _billingData: UpdateBillingDto) { // TODO: Sync to WHMCS custom fields throw new Error("Not implemented"); } }