-
Notifications
You must be signed in to change notification settings - Fork 2
feat: SP1 프로필 수정, 매칭 조건 수정 api 연결 #326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
9b7f840
306fc2a
f3bda12
a24ff62
42dfe33
e88fe20
2ab45b9
f70b2b5
8e866e3
73b055f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,16 @@ | ||
| export const PROFILE_SYNC_MATE = ['같은 팀 메이트', '상관없어요']; | ||
|
|
||
| export const PROFILE_VIEWING_STYLE = [ | ||
| { | ||
| id: 1, | ||
| label: '열정 응원러', | ||
| }, | ||
| { | ||
| id: 2, | ||
| label: '경기 집중러', | ||
| }, | ||
| { | ||
| id: 3, | ||
| label: '직관 먹방러', | ||
| }, | ||
| ]; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { NicknameSchema } from '@pages/sign-up/schema/validation-schema'; | ||
| import type { z } from 'zod'; | ||
|
|
||
| export const EditProfileSchema = NicknameSchema.pick({ | ||
| nickname: true, | ||
| information: true, | ||
| }); | ||
|
|
||
| export type EditProfileValues = z.infer<typeof EditProfileSchema>; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,15 @@ | ||||||||||||||||||||||||||||||||||||||||||
| import { post } from '@apis/base/http'; | ||||||||||||||||||||||||||||||||||||||||||
| import { patch, post, put } from '@apis/base/http'; | ||||||||||||||||||||||||||||||||||||||||||
| import { END_POINT } from '@constants/api'; | ||||||||||||||||||||||||||||||||||||||||||
| import { USER_KEY } from '@constants/query-key'; | ||||||||||||||||||||||||||||||||||||||||||
| import queryClient from '@libs/query-client'; | ||||||||||||||||||||||||||||||||||||||||||
| import { mutationOptions } from '@tanstack/react-query'; | ||||||||||||||||||||||||||||||||||||||||||
| import type { responseTypes } from '@/shared/types/base-types'; | ||||||||||||||||||||||||||||||||||||||||||
| import type { postUserInfoNicknameRequest, postUserInfoRequest } from '@/shared/types/user-types'; | ||||||||||||||||||||||||||||||||||||||||||
| import type { | ||||||||||||||||||||||||||||||||||||||||||
| postEditProfileRequest, | ||||||||||||||||||||||||||||||||||||||||||
| postMatchConditionRequest, | ||||||||||||||||||||||||||||||||||||||||||
| postUserInfoNicknameRequest, | ||||||||||||||||||||||||||||||||||||||||||
| postUserInfoRequest, | ||||||||||||||||||||||||||||||||||||||||||
| } from '@/shared/types/user-types'; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| export const userMutations = { | ||||||||||||||||||||||||||||||||||||||||||
| NICKNAME: () => | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -32,4 +37,23 @@ export const userMutations = { | |||||||||||||||||||||||||||||||||||||||||
| console.error('로그아웃 실패', err); | ||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| EDIT_PROFILE: () => | ||||||||||||||||||||||||||||||||||||||||||
| mutationOptions<responseTypes, Error, postEditProfileRequest>({ | ||||||||||||||||||||||||||||||||||||||||||
| mutationKey: USER_KEY.EDIT_PROFILE(), | ||||||||||||||||||||||||||||||||||||||||||
| mutationFn: ({ field, value }) => put(END_POINT.POST_EDIT_PROFILE, { field, value }), | ||||||||||||||||||||||||||||||||||||||||||
| onSuccess: async () => { | ||||||||||||||||||||||||||||||||||||||||||
| queryClient.invalidateQueries({ queryKey: USER_KEY.ALL }); | ||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||
| onError: (err) => { | ||||||||||||||||||||||||||||||||||||||||||
| console.error('수정에 실패했어요', err); | ||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| EDIT_MATCH_CONDITION: () => | ||||||||||||||||||||||||||||||||||||||||||
| mutationOptions<postMatchConditionRequest, Error, postMatchConditionRequest>({ | ||||||||||||||||||||||||||||||||||||||||||
| mutationKey: USER_KEY.MATCH_CONDITION(), | ||||||||||||||||||||||||||||||||||||||||||
| mutationFn: ({ team, teamAllowed, style, genderPreference }) => | ||||||||||||||||||||||||||||||||||||||||||
| patch(END_POINT.MATCH_CONDITION, { team, teamAllowed, style, genderPreference }), | ||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+58
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion EDIT_MATCH_CONDITION: 반환 타입/캐시 무효화 보완
아래처럼 수정하세요: - EDIT_MATCH_CONDITION: () =>
- mutationOptions<postMatchConditionRequest, Error, postMatchConditionRequest>({
+ EDIT_MATCH_CONDITION: () =>
+ mutationOptions<responseTypes, Error, postMatchConditionRequest>({
mutationKey: USER_KEY.MATCH_CONDITION(),
- mutationFn: ({ team, teamAllowed, style, genderPreference }) =>
- patch(END_POINT.MATCH_CONDITION, { team, teamAllowed, style, genderPreference }),
+ mutationFn: ({ team, teamAllowed, style, genderPreference }) =>
+ patch<responseTypes>(END_POINT.MATCH_CONDITION, {
+ team,
+ teamAllowed,
+ style,
+ genderPreference,
+ }),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: USER_KEY.MATCH_CONDITION() });
+ },
}),📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저장 버튼이 한 번 클릭 후 영구 비활성화되는 버그
isSubmit를true로 바꾼 뒤 다시false로 복구하지 않아 버튼이 계속 비활성화됩니다. 뮤테이션의isPending을 사용해 상태를 추적하거나onSettled에서 복구하세요. 아래는isPending을 쓰는 간단한 수정안입니다.Also applies to: 33-35, 81-82, 83-93
🤖 Prompt for AI Agents