From c935f305e25199ff3979b638aa158aa3117da28c Mon Sep 17 00:00:00 2001 From: balibabu Date: Mon, 8 Jun 2026 14:33:52 +0800 Subject: [PATCH] Fix: The time zone is not displayed on the personal profile page. (#15759) ### What problem does this PR solve? Fix: The time zone is not displayed on the personal profile page. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- .../user-setting/profile/hooks/use-profile.ts | 20 +++++++++---------- web/src/pages/user-setting/profile/index.tsx | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/web/src/pages/user-setting/profile/hooks/use-profile.ts b/web/src/pages/user-setting/profile/hooks/use-profile.ts index ffcd6ae134..a349da5cc1 100644 --- a/web/src/pages/user-setting/profile/hooks/use-profile.ts +++ b/web/src/pages/user-setting/profile/hooks/use-profile.ts @@ -4,6 +4,7 @@ import { useFetchUserInfo, useSaveSetting, } from '@/hooks/use-user-setting-request'; +import { TimezoneList } from '@/pages/user-setting/constants'; import { rsaPsw } from '@/utils'; import { useCallback, useEffect, useState } from 'react'; @@ -31,6 +32,14 @@ export const modalTitle = { [EditType.editPassword]: 'Edit Password', } as const; +const normalizeTimezone = (tz: string | undefined): string => { + if (!tz) return ''; + // Support both backend format "UTC+8\tAsia/Shanghai" and frontend format "GMT+08:00 Asia/Shanghai" + const parts = tz.split(/\t|\s+/); + const ianaName = parts.length > 1 ? parts[parts.length - 1] : tz; + return TimezoneList.find((item) => item.id === ianaName)?.name ?? ''; +}; + export const useProfile = () => { const { data: userInfo } = useFetchUserInfo(); const [profile, setProfile] = useState({ @@ -51,13 +60,9 @@ export const useProfile = () => { } = useSaveSetting(); useEffect(() => { - // form.setValue('currPasswd', ''); // current password const profile = { userName: userInfo.nickname, - timeZone: - userInfo.timezone === ' UTC+8\tAsia/Shanghai' - ? DEFAULT_TIMEZONE.name - : userInfo.timezone, + timeZone: normalizeTimezone(userInfo.timezone) || DEFAULT_TIMEZONE?.name, avatar: userInfo.avatar || '', email: userInfo.email, currPasswd: userInfo.password, @@ -93,7 +98,6 @@ export const useProfile = () => { payload.password = rsaPsw(newProfile.currPasswd!) as string; payload.new_password = rsaPsw(newProfile.newPasswd!) as string; } - console.log('payload', payload); if (editType === EditType.editName && payload.nickname) { saveSetting({ nickname: payload.nickname }); setProfile(newProfile); @@ -109,7 +113,6 @@ export const useProfile = () => { }); setProfile(newProfile); } - // saveSetting(payload); }; const handleEditClick = useCallback( @@ -127,12 +130,9 @@ export const useProfile = () => { }, []); const handleSave = (data: ProfileData) => { - console.log('handleSave', data); const newProfile = { ...profile, ...data }; onSubmit(newProfile); - // setIsEditing(false); - // setEditForm({}); }; const handleAvatarUpload = (avatar: string) => { diff --git a/web/src/pages/user-setting/profile/index.tsx b/web/src/pages/user-setting/profile/index.tsx index 9f330fab33..0356454311 100644 --- a/web/src/pages/user-setting/profile/index.tsx +++ b/web/src/pages/user-setting/profile/index.tsx @@ -216,7 +216,7 @@ const ProfilePage: FC = () => {
- {profile.currPasswd ? '********' : ''} + ********