import { ApiResponse } from '@goodgo/types'; import { apiClient } from './client'; /** * EN: User profile interface * VI: Interface profile người dùng */ export interface UserProfile { id: string; userId: string; firstName?: string; lastName?: string; phone?: string; phoneVerified?: boolean; avatarUrl?: string; customFields?: Record; preferences?: Record; metadata?: Record; createdAt: string; updatedAt: string; } /** * EN: Update user profile DTO * VI: DTO cập nhật profile người dùng */ export interface UpdateUserProfileDto { firstName?: string; lastName?: string; phone?: string; avatarUrl?: string; customFields?: Record; preferences?: Record; metadata?: Record; } /** * EN: User API service for profile management * VI: Service API người dùng để quản lý profile */ export const userApi = { /** * EN: Get user profile by user ID * VI: Lấy profile người dùng theo user ID * * @param userId - User ID / ID người dùng */ getProfile: async (userId: string): Promise> => { return apiClient.get(`/identity/users/${userId}/profile`); }, /** * EN: Update user profile * VI: Cập nhật profile người dùng * * @param userId - User ID / ID người dùng * @param data - Profile data to update / Dữ liệu profile cần cập nhật */ updateProfile: async ( userId: string, data: UpdateUserProfileDto ): Promise> => { return apiClient.put(`/identity/users/${userId}/profile`, data); }, /** * EN: Upload avatar image * VI: Upload ảnh avatar * * @param userId - User ID / ID người dùng * @param avatarUrl - Avatar URL / URL avatar */ uploadAvatar: async ( userId: string, avatarUrl: string ): Promise> => { return apiClient.post(`/identity/users/${userId}/profile/avatar`, { avatarUrl, }); }, /** * EN: Delete avatar * VI: Xóa avatar * * @param userId - User ID / ID người dùng */ deleteAvatar: async (userId: string): Promise => { return apiClient.delete(`/identity/users/${userId}/profile/avatar`); }, };