import { api } from './api'; import { API_ENDPOINTS } from '@/utils/constants'; import { User, ApiResponse } from '@/types'; export interface UpdateProfileData { firstName?: string; lastName?: string; phone?: string; } export interface ChangePasswordData { currentPassword: string; newPassword: string; } export const userService = { // Get user profile getProfile: async (): Promise => { const response = await api.get>( API_ENDPOINTS.USER.PROFILE ); return response.data!; }, // Update user profile updateProfile: async (data: UpdateProfileData): Promise => { const response = await api.put>( API_ENDPOINTS.USER.UPDATE_PROFILE, data ); return response.data!; }, // Change password changePassword: async (data: ChangePasswordData): Promise => { await api.post(API_ENDPOINTS.USER.CHANGE_PASSWORD, data); }, // Archive account (désactive le compte au lieu de le supprimer) archiveAccount: async (): Promise => { await api.put(API_ENDPOINTS.USER.UPDATE_PROFILE, { isActive: false }); }, // Delete account (kept for backwards compatibility) deleteAccount: async (): Promise => { await api.delete(API_ENDPOINTS.USER.DELETE_ACCOUNT); }, };