Skip to content

Commit

Permalink
Merge pull request #160 from ruby10127130/feature/auth/add-migrate-fo…
Browse files Browse the repository at this point in the history
…r-redux-user

feat: add workaround to migrate redux updateUser to authDispatch.upda…
  • Loading branch information
JohnsonMao authored Dec 14, 2024
2 parents d300c67 + 033a524 commit 3496bda
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions contexts/Auth/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export function AuthProvider({ children }: PropsWithChildren) {
// TODO: remove after removed redux
if ((input as { _id?: string })?._id) {
dispatch({ type: ActionTypes.UPDATE_USER, payload: input as any });
return;
}

switch (state.loginStatus) {
Expand Down
38 changes: 19 additions & 19 deletions services/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,26 @@ export const createUserProfile = (user: CreateUserProfile) => {
};

export const updateUserProfileSchema = z.object({
id: z.string(),
email: z.string(),
name: z.string(),
birthDay: z.string(),
gender: z.string(),
roleList: z.array(z.string()),
id: z.string().optional(),
email: z.string().optional(),
name: z.string().optional(),
birthDay: z.string().optional(),
gender: z.string().optional(),
roleList: z.array(z.string()).optional(),
contactList: z.object({
instagram: z.string(),
facebook: z.string(),
discord: z.string(),
line: z.string(),
}),
wantToDoList: z.array(z.string()),
educationStage: z.string(),
location: z.string(),
tagList: z.array(z.string()),
selfIntroduction: z.string(),
share: z.string(),
isOpenLocation: z.boolean(),
isOpenProfile: z.boolean(),
instagram: z.string().optional(),
facebook: z.string().optional(),
discord: z.string().optional(),
line: z.string().optional(),
}).optional(),
wantToDoList: z.array(z.string()).optional(),
educationStage: z.string().optional(),
location: z.string().optional(),
tagList: z.array(z.string()).optional(),
selfIntroduction: z.string().optional(),
share: z.string().optional(),
isOpenLocation: z.boolean().optional(),
isOpenProfile: z.boolean().optional(),
});

export type UpdateUserProfile = z.infer<typeof updateUserProfileSchema>;
Expand Down

0 comments on commit 3496bda

Please sign in to comment.