1. Change Password fixed. 2. Personal Data implemented. 3. New alerts style. 4. Better dropdowns.

This commit is contained in:
AG
2025-11-19 22:52:32 +02:00
parent bb705c8a63
commit 8cc9ab29b7
14 changed files with 1266 additions and 632 deletions

View File

@@ -54,19 +54,39 @@ export const adminResetPassword = (userId: string, newPass: string) => {
// Admin only
};
export const updateUserProfile = async (userId: string, profile: Partial<UserProfile>) => {
// Not implemented in backend yet as a separate endpoint,
// but typically this would be a PATCH /users/me/profile
// For now, let's skip or implement if needed.
// The session save updates weight.
export const updateUserProfile = async (userId: string, profile: Partial<UserProfile>): Promise<{ success: boolean; error?: string }> => {
try {
const res = await api.patch('/auth/profile', { userId, profile });
return res;
} catch (e) {
return { success: false, error: 'Failed to update profile' };
}
};
export const changePassword = (userId: string, newPassword: string) => {
// Not implemented
export const changePassword = async (userId: string, newPassword: string) => {
try {
const res = await api.post('/auth/change-password', { userId, newPassword });
if (!res.success) {
console.error('Failed to change password:', res.error);
}
return res;
} catch (e) {
console.error(e);
return { success: false, error: 'Network error' };
}
};
export const getCurrentUserProfile = (userId: string): UserProfile | undefined => {
// This was synchronous. Now it needs to be async or fetched on load.
// For now, we return undefined and let the app fetch it.
return undefined;
}
};
export const getMe = async (): Promise<{ success: boolean; user?: User; error?: string }> => {
try {
const res = await api.get('/auth/me');
return res;
} catch (e) {
return { success: false, error: 'Failed to fetch user' };
}
};