the-tip-top-frontend/services/user.service.ts
soufiane dce1559a32 feat: improve user management and profile features
- Replace email verification status with active/inactive status
- Add user archiving (soft delete) instead of hard delete
- Add search by name/email in user management
- Add status filter (active/inactive) in user management
- Simplify actions to show only "Détails" button
- Add Google Maps with clickable marker on contact page
- Update button labels from "Désactiver" to "Supprimer"

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 13:59:52 +01:00

49 lines
1.3 KiB
TypeScript

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<User> => {
const response = await api.get<ApiResponse<User>>(
API_ENDPOINTS.USER.PROFILE
);
return response.data!;
},
// Update user profile
updateProfile: async (data: UpdateProfileData): Promise<User> => {
const response = await api.put<ApiResponse<User>>(
API_ENDPOINTS.USER.UPDATE_PROFILE,
data
);
return response.data!;
},
// Change password
changePassword: async (data: ChangePasswordData): Promise<void> => {
await api.post(API_ENDPOINTS.USER.CHANGE_PASSWORD, data);
},
// Archive account (désactive le compte au lieu de le supprimer)
archiveAccount: async (): Promise<void> => {
await api.put(API_ENDPOINTS.USER.UPDATE_PROFILE, { isActive: false });
},
// Delete account (kept for backwards compatibility)
deleteAccount: async (): Promise<void> => {
await api.delete(API_ENDPOINTS.USER.DELETE_ACCOUNT);
},
};