fix(settings): enable profile save and avatar selection

This commit is contained in:
zetaloop
2026-02-22 08:30:40 +08:00
parent 4beb610f23
commit 2ade1780c1
2 changed files with 64 additions and 5 deletions
+14
View File
@@ -12,6 +12,7 @@ interface AuthState {
submitVerification: (role: UserRole) => void
approveVerification: (role: UserRole) => void
rejectVerification: (role: UserRole, reason: string) => void
updateProfile: (patch: { nickname?: string; bio?: string; avatar?: string }) => void
login: (user: User, verifiedRoles?: UserRole[]) => void
logout: () => void
}
@@ -83,6 +84,19 @@ export const useAuthStore = create<AuthState>((set, get) => ({
},
}
}),
updateProfile: (patch) =>
set((state) => {
if (!state.user) return state
return {
user: {
...state.user,
nickname: patch.nickname ?? state.user.nickname,
bio: patch.bio ?? state.user.bio,
avatar: patch.avatar ?? state.user.avatar,
},
}
}),
login: (user, verifiedRoles = ["consumer"]) =>
set({
isAuthenticated: true,