Files
maternal-app/maternal-web/lib/api/users.ts
Andrei 3f31eddeca feat: Add user profile photo upload with base64 encoding
Added complete photo upload support for user profiles:
- Added photoUrl field to User entity and all auth responses
- Created migration V008 for photo_url column in users table
- Updated UpdateProfileDto to include photoUrl validation
- Modified auth.service.ts to handle photoUrl in all user responses (register, login, getUserById, updateProfile, refreshAccessToken, loginWithExternalAuth)
- Updated AuthResponse interface to include photoUrl
- Updated frontend User and UserProfile interfaces to include photoUrl
- Updated AppShell to display user photoUrl in header avatar
- Fixed ChildDialog to remove invalid props from PhotoUpload component

The photo upload uses base64 encoding (max 5MB) for simplicity and works across all environments. Future enhancement can migrate to CDN/object storage.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-04 08:57:35 +00:00

35 lines
738 B
TypeScript

import apiClient from './client';
export interface UserPreferences {
notifications?: boolean;
emailUpdates?: boolean;
darkMode?: boolean;
}
export interface UpdateProfileData {
name?: string;
photoUrl?: string;
timezone?: string;
preferences?: UserPreferences;
}
export interface UserProfile {
id: string;
email: string;
name: string;
photoUrl?: string;
role: string;
locale: string;
emailVerified: boolean;
preferences?: UserPreferences;
families?: string[];
}
export const usersApi = {
// Update user profile
updateProfile: async (data: UpdateProfileData): Promise<UserProfile> => {
const response = await apiClient.patch('/api/v1/auth/profile', data);
return response.data.data;
},
};