feat: 添加用户资料中的邮箱和地址字段,并更新相关接口和页面

This commit is contained in:
2026-05-29 01:59:05 +08:00
parent 201f80811a
commit a8409ad76b
6 changed files with 111 additions and 42 deletions

View File

@@ -12,6 +12,8 @@ export interface UserProfile {
name: string;
age: number | null;
phone: string;
email: string;
address: string;
avatar_url: string | null;
lastPeriodDate: string; // YYYY-MM-DD
dueDate: string;
@@ -36,6 +38,8 @@ const DEFAULT_PROFILE: UserProfile = {
name: "",
age: null,
phone: "",
email: "",
address: "",
avatar_url: null,
lastPeriodDate: "",
dueDate: "",
@@ -156,6 +160,8 @@ function mapDtoToProfile(dto: UserProfileDTO): UserProfile {
name: dto.name || "",
age: dto.age,
phone: dto.phone || "",
email: dto.email || "",
address: dto.address || "",
avatar_url: dto.avatar_url || null,
lastPeriodDate: lmpDate,
dueDate,
@@ -180,7 +186,7 @@ interface UserContextValue {
updateUserRemote: (data: Partial<UserProfile>) => Promise<void>;
setToken: (token: string) => void;
setTokenAndUser: (token: string, info: BasicUserInfo) => void;
fetchProfile: () => Promise<void>;
fetchProfile: () => Promise<UserProfileDTO | null>;
logout: () => void;
}
@@ -220,6 +226,8 @@ export function UserProvider({ children }: { children: ReactNode }) {
if (data.name !== undefined) payload.name = data.name;
if (data.age !== undefined) payload.age = data.age;
if (data.phone !== undefined) payload.phone = data.phone;
if (data.email !== undefined) payload.email = data.email;
if (data.address !== undefined) payload.address = data.address;
if (data.height !== undefined) payload.height = data.height;
if (data.prePregnancyWeight !== undefined) payload.pre_pregnancy_weight = data.prePregnancyWeight;
if (data.currentWeight !== undefined) payload.current_weight = data.currentWeight;