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)
This commit is contained in:
balibabu
2026-06-08 14:33:52 +08:00
committed by GitHub
parent 220ee9dbfb
commit c935f305e2
2 changed files with 11 additions and 11 deletions

View File

@@ -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<ProfileData>({
@@ -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) => {

View File

@@ -216,7 +216,7 @@ const ProfilePage: FC = () => {
</label>
<div className="flex-1 flex items-center gap-4">
<div className="text-sm text-text-primary border border-border-button flex-1 rounded-md py-1.5 px-2">
{profile.currPasswd ? '********' : ''}
<span className="inline-block translate-y-0.5">********</span>
</div>
<Button
variant="outline"