1. Change Password fixed. 2. Personal Data implemented. 3. New alerts style. 4. Better dropdowns.
This commit is contained in:
@@ -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' };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,6 +29,7 @@ const translations = {
|
||||
change_pass_desc: 'This is your first login. Please set a new password.',
|
||||
change_pass_new: 'New Password',
|
||||
change_pass_save: 'Save & Login',
|
||||
change_pass_error: 'Error changing password',
|
||||
passwords_mismatch: 'Passwords do not match',
|
||||
register_title: 'Create Account',
|
||||
confirm_password: 'Confirm Password',
|
||||
@@ -145,6 +146,7 @@ const translations = {
|
||||
archive: 'Archive',
|
||||
unarchive: 'Unarchive',
|
||||
show_archived: 'Show Archived',
|
||||
profile_saved: 'Profile saved successfully',
|
||||
},
|
||||
ru: {
|
||||
// Tabs
|
||||
@@ -167,6 +169,7 @@ const translations = {
|
||||
change_pass_desc: 'Это ваш первый вход. Пожалуйста, установите новый пароль.',
|
||||
change_pass_new: 'Новый пароль',
|
||||
change_pass_save: 'Сохранить и войти',
|
||||
change_pass_error: 'Ошибка смены пароля',
|
||||
passwords_mismatch: 'Пароли не совпадают',
|
||||
register_title: 'Регистрация',
|
||||
confirm_password: 'Подтвердите пароль',
|
||||
@@ -283,6 +286,7 @@ const translations = {
|
||||
archive: 'Архив',
|
||||
unarchive: 'Вернуть',
|
||||
show_archived: 'Показать архивные',
|
||||
profile_saved: 'Профиль успешно сохранен',
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user