Files
pos-system/apps/web-client/src/services/api/user.api.ts
Ho Ngoc Hai c088de53c3 Update dependencies and enhance Tailwind CSS configuration for web applications
- Added new dependencies including clsx, lucide-react, recharts, and various Radix UI components to improve UI functionality.
- Upgraded Tailwind CSS to version 4.0.0 and updated configuration to utilize CSS variables for theming and responsive design.
- Introduced global styles and improved accessibility features in the layout and components.
- Removed outdated login page and refactored authentication store for better state management.
- Enhanced API service with additional authentication methods and improved error handling.

These changes aim to modernize the web applications and improve user experience through better design and functionality.
2026-01-02 09:41:40 +07:00

93 lines
2.3 KiB
TypeScript

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<string, unknown>;
preferences?: Record<string, unknown>;
metadata?: Record<string, unknown>;
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<string, unknown>;
preferences?: Record<string, unknown>;
metadata?: Record<string, unknown>;
}
/**
* 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<ApiResponse<UserProfile>> => {
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<ApiResponse<UserProfile>> => {
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<ApiResponse<UserProfile>> => {
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<ApiResponse> => {
return apiClient.delete(`/identity/users/${userId}/profile/avatar`);
},
};