fix: Update updateProfile service to handle timezone and full preferences including timeFormat

This commit is contained in:
2025-10-03 12:28:54 +00:00
parent 9c7bdb68d5
commit 66c8d4c41e

View File

@@ -374,10 +374,13 @@ export class AuthService {
userId: string, userId: string,
updateData: { updateData: {
name?: string; name?: string;
timezone?: string;
preferences?: { preferences?: {
notifications?: boolean; notifications?: boolean;
emailUpdates?: boolean; emailUpdates?: boolean;
darkMode?: boolean; darkMode?: boolean;
measurementUnit?: 'metric' | 'imperial';
timeFormat?: '12h' | '24h';
}; };
}, },
): Promise<{ success: boolean; data: any }> { ): Promise<{ success: boolean; data: any }> {
@@ -403,6 +406,12 @@ export class AuthService {
this.logger.log(`Updated user.name to: "${user.name}"`); this.logger.log(`Updated user.name to: "${user.name}"`);
} }
// Update timezone if provided
if (updateData.timezone !== undefined) {
user.timezone = updateData.timezone;
this.logger.log(`Updated user.timezone to: "${user.timezone}"`);
}
// Update preferences if provided // Update preferences if provided
if (updateData.preferences !== undefined) { if (updateData.preferences !== undefined) {
user.preferences = updateData.preferences; user.preferences = updateData.preferences;
@@ -411,7 +420,7 @@ export class AuthService {
const updatedUser = await this.userRepository.save(user); const updatedUser = await this.userRepository.save(user);
this.logger.log( this.logger.log(
`User saved. Updated name: "${updatedUser.name}", preferences:`, `User saved. Updated name: "${updatedUser.name}", timezone: "${updatedUser.timezone}", preferences:`,
updatedUser.preferences, updatedUser.preferences,
); );
@@ -423,6 +432,7 @@ export class AuthService {
name: updatedUser.name, name: updatedUser.name,
role: 'user', role: 'user',
locale: updatedUser.locale, locale: updatedUser.locale,
timezone: updatedUser.timezone,
emailVerified: updatedUser.emailVerified, emailVerified: updatedUser.emailVerified,
preferences: updatedUser.preferences, preferences: updatedUser.preferences,
}, },