feat: implement user profile endpoints (task 31)
- Add GET /api/users/:id for profile retrieval with stats - Add PATCH /api/users/:id for profile updates - Add GET /api/users/:id/reports to fetch user's reports - Add GET /api/users/:id/events to fetch user's events (registered & organized) - Add PATCH /api/users/:id/preferences for notification settings - Add POST /api/users/:id/calculate-impact for impact score calculation - Create userService with all business logic - Create userController with request handling - Create userRoutes and register in main server - Update frontend userService with new endpoints - Add comprehensive documentation in USER_PROFILE_ENDPOINTS.md - Add test script for manual endpoint testing Requirements satisfied: 6.3, 6.4, 6.5, 10.4
This commit is contained in:
@@ -24,8 +24,16 @@ export interface UpdateProfileDTO {
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
username?: string;
|
||||
notificationEmail?: boolean;
|
||||
notificationInApp?: boolean;
|
||||
}
|
||||
|
||||
export interface NotificationPreferences {
|
||||
notificationEmail: boolean;
|
||||
notificationInApp: boolean;
|
||||
areasOfInterest?: Array<{
|
||||
lat: number;
|
||||
lng: number;
|
||||
radius: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
export const userService = {
|
||||
@@ -63,4 +71,21 @@ export const userService = {
|
||||
async getUserActivity(userId: string): Promise<UserActivity[]> {
|
||||
return apiClient.get<UserActivity[]>(`/users/${userId}/activity`);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update notification preferences
|
||||
*/
|
||||
async updateNotificationPreferences(
|
||||
userId: string,
|
||||
preferences: NotificationPreferences
|
||||
): Promise<NotificationPreferences> {
|
||||
return apiClient.patch<NotificationPreferences>(`/users/${userId}/preferences`, preferences);
|
||||
},
|
||||
|
||||
/**
|
||||
* Calculate and update user impact score
|
||||
*/
|
||||
async calculateImpactScore(userId: string): Promise<{ impactScore: number }> {
|
||||
return apiClient.post<{ impactScore: number }>(`/users/${userId}/calculate-impact`, {});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user