import { UserService } from "@/services/userService";
import { AuthenticatedRequest, UpdateUserRequest } from "@/types";
import { Response } from "express";

export class UserController {
  static async updateProfile(req: AuthenticatedRequest, res: Response) {
    if (!req.user) {
      res.status(401).json({ success: false, error: "Unauthorized" });
      return;
    }

    const data: UpdateUserRequest = req.body;
    const result = await UserService.updateProfile(req.user.userId, data);

    res.status(result.success ? 200 : 400).json(result);
  }
}
