Skip to content

feat: SP1 프로필 수정, 매칭 조건 수정 api 연결#326

Merged
heesunee merged 10 commits intodevelopfrom
feat/#325/edit-profile-api
Aug 31, 2025
Merged

feat: SP1 프로필 수정, 매칭 조건 수정 api 연결#326
heesunee merged 10 commits intodevelopfrom
feat/#325/edit-profile-api

Conversation

@heesunee
Copy link
Contributor

@heesunee heesunee commented Aug 31, 2025

#️⃣ Related Issue

Closes #325

☀️ New-insight

  • 닉네임 수정 중복확인 제외 구현 완료
  • 서버에서 같은 팀 메이트와 보고 싶어요 -> 같은 팀 메이트로 값 주고 받는거 수정중
  • 이따가 상세 pr 작성하겠습니다

💎 PR Point

📸 Screenshot

Summary by CodeRabbit

  • New Features
    • 프로필 수정 페이지가 서버와 실시간 연동되어 닉네임·소개와 매칭 조건(응원팀, 상대팀 허용, 관람 스타일, 성별 선호)을 직접 수정·저장할 수 있습니다.
    • 폼 검증과 오류 메시지로 입력 유효성을 강화하고 초기값을 서버에서 자동 로딩합니다.
    • 변경 사항이 있을 때만 매칭 조건 저장 버튼이 활성화됩니다.
    • 무응원팀 선택 시 관련 옵션이 자동 비활성화되고, 관람 스타일 선택지가 추가되었습니다.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 31, 2025

Deploying mateball-client with  Cloudflare Pages  Cloudflare Pages

Latest commit: 73b055f
Status: ✅  Deploy successful!
Preview URL: https://80ae7509.mateball-client.pages.dev
Branch Preview URL: https://feat--325-edit-profile-api.mateball-client.pages.dev

View logs

@coderabbitai
Copy link

coderabbitai bot commented Aug 31, 2025

Walkthrough

프로필 수정 페이지가 모킹에서 실제 API 연동으로 전환되었습니다. HTTP PUT 헬퍼와 사용자 쿼리/뮤테이션(매칭 조건 포함), 엔드포인트·쿼리키·타입이 추가되었고, 폼은 react-hook-form + zod로 재구성되어 닉네임/소개·매칭 조건 수정 흐름이 구현되었습니다.

Changes

Cohort / File(s) Summary
Edit Profile Page & Form
src/pages/edit-profile/edit-profile.tsx
모킹 제거, react-query로 user info/MATCH_CONDITION 조회 및 EDIT_PROFILE/EDIT_MATCH_CONDITION 뮤테이션 사용. react-hook-form + zod로 폼 재구성(닉네임·소개 개별 제출, 매칭 조건 dirty 계산/제출).
Edit Profile Constants
src/pages/edit-profile/constants/edit-profile.ts
PROFILE_VIEWING_STYLE 추가 및 PROFILE_SYNC_MATE 함께 내보냄(뷰잉 스타일 상수 이동/갱신).
Validation Schema
src/pages/edit-profile/schema/EditProfileSchema.ts
EditProfileSchema, EditProfileValues 신규 추가(닉네임·소개 유효성).
HTTP Base Client
src/shared/apis/base/http.ts
put<T>() 헬퍼 추가(응답 data 반환 패턴 일관화).
User Mutations
src/shared/apis/user/user-mutations.ts
EDIT_PROFILE(PUT) 및 EDIT_MATCH_CONDITION(PATCH) 뮤테이션 추가(캐시 무효화, 에러 로깅/성공 시 리로드 등).
User Queries
src/shared/apis/user/user-queries.ts
MATCH_CONDITION 쿼리 추가 및 USER_INFO 쿼리 엔드포인트 일부 갱신.
API Endpoints
src/shared/constants/api.ts
GET_USER_INFO, POST_INFO_NICKNAME, POST_EDIT_PROFILE, MATCH_CONDITION 엔드포인트 추가.
Query Keys
src/shared/constants/query-key.ts
EDIT_PROFILE, MATCH_CONDITION USER_KEY 항목 추가.
User Types
src/shared/types/user-types.ts
postEditProfileRequest, getMatchConditionResponse, postMatchConditionRequest 인터페이스 추가.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant P as EditProfilePage
  participant RQ as ReactQuery
  participant API as HTTP Client
  participant S as Server

  U->>P: 페이지 진입
  P->>RQ: 쿼리: GET user info, GET match-condition
  RQ->>API: GET /v1/users/info, GET /v2/users/match-condition
  API->>S: 요청 전달
  S-->>API: 응답
  API-->>RQ: 데이터 반환
  RQ-->>P: 초기값 바인딩

  U->>P: 닉네임/소개 제출
  P->>RQ: mutation EDIT_PROFILE (PUT /v2/users/info)
  RQ->>API: PUT { field, value }
  API->>S: 요청
  S-->>API: 성공
  API-->>RQ: 응답
  RQ-->>P: onSuccess (USER_KEY.ALL 무효화, 페이지 리로드)

  U->>P: 매칭 조건 수정 제출
  P->>RQ: mutation EDIT_MATCH_CONDITION (PATCH /v2/users/match-condition)
  RQ->>API: PATCH { team, teamAllowed, style, genderPreference }
  API->>S: 요청
  S-->>API: 성공
  API-->>RQ: 응답
  RQ-->>P: 완료 (버튼 상태/dirty 초기화)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Assessment against linked issues

Objective Addressed Explanation
프로필 수정 API를 연결 (#325)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
매칭 조건 조회 쿼리 및 관련 타입/엔드포인트 추가 (src/shared/apis/user/user-queries.ts, src/shared/types/user-types.ts, src/shared/constants/api.ts) 이슈(#325)는 “프로필 수정 API 연결”을 요구하며, MATCH_CONDITION 조회·타입·엔드포인트 추가는 원문 요구사항에 명시되어 있지 않습니다.
매칭 조건 수정 뮤테이션 추가 (src/shared/apis/user/user-mutations.ts) 프로필 필드 편집(EDIT_PROFILE)과 별도로 매칭 조건 PATCH 뮤테이션이 추가되어 이슈 범위에서 벗어날 가능성이 있습니다.
뷰잉 스타일 상수 이동/명칭 변경 (src/pages/edit-profile/constants/edit-profile.ts, src/pages/edit-profile/edit-profile.tsx) VIEWING_STYLE의 위치/명칭 변경 및 UI 옵션 확장은 단순 API 연결 목적과 직접적 연관성이 명확하지 않습니다.

Possibly related PRs

Suggested reviewers

  • Dubabbi
  • bongtta
  • yeeeww

Poem

"폼에 당근을 올려요, 닉네임 한입에 쏙,
푸트와 패치가 춤추네, 서버에 톡톡! 🥕
매칭 조건은 깡충깡충, 쿼리로 불러와,
토끼가 말하네—모킹은 이젠 안녕! ✨"

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#325/edit-profile-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added feat new feature 희선 labels Aug 31, 2025
@heesunee heesunee changed the title feat: 프로필 수정, 매칭 조건 수정 api 연결 feat: SP1 프로필 수정, 매칭 조건 수정 api 연결 Aug 31, 2025
@github-actions
Copy link

MATEBALL-STORYBOOK
⚾ Storybook 배포가 완료되었습니다!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (11)
src/shared/constants/api.ts (1)

15-16: 상수명 재정의: HTTP 메서드와 버전 표기 일치시키기

  • src/shared/constants/api.ts (15–16행)
    • POST_EDIT_PROFILEPUT_EDIT_PROFILE
    • MATCH_CONDITIONMATCH_CONDITION_V2 (기존 POST_MATCH_CONDITION은 v1 호출용으로 유지)
  • 변경된 상수명에 맞춰 호출부 일괄 업데이트
    • put(END_POINT.POST_EDIT_PROFILE) → put(END_POINT.PUT_EDIT_PROFILE) (src/shared/apis/user/user-mutations.ts:44)
    • patch/get 호출 시 END_POINT.MATCH_CONDITION → END_POINT.MATCH_CONDITION_V2 (src/shared/apis/user/user-mutations.ts:57, src/shared/apis/user/user-queries.ts:25)

상수명과 실제 HTTP 메서드·버전이 일대일 대응하도록 리네임하면 가독성과 유지보수성이 높아집니다.

src/shared/apis/base/http.ts (1)

15-17: HTTP 메서드 커버리지 완성도 높이기(DELETE 추가 권장)

삭제 요청도 동일 패턴으로 자주 필요합니다. 예약어 충돌을 피해 del 네이밍을 권장합니다.

 export function put<T>(...args: Parameters<typeof instance.put>): Promise<T> {
   return instance.put<T>(...args).then((res) => res.data);
 }
+
+export function del<T>(...args: Parameters<typeof instance.delete>): Promise<T> {
+  return instance.delete<T>(...args).then((res) => res.data);
+}
src/pages/edit-profile/constants/edit-profile.ts (2)

3-16: 리터럴 타입 보존 및 오타 방지 위해 as const 권장

소비 측에서 label을 좁은 리터럴 타입으로 활용할 수 있고, 이후 값 비교 시 안전합니다.

 export const PROFILE_VIEWING_STYLE = [
   {
     id: 1,
     label: '열정 응원러',
   },
   {
     id: 2,
     label: '경기 집중러',
   },
   {
     id: 3,
     label: '직관 먹방러',
   },
-];
+ ] as const;

3-16: 표시용 label과 전송용 value 분리 고려

서버 교환값과 UI 문구가 분리되면 번역/카피 변경에도 API 계약이 안정적입니다. 예: { id, value: 'PASSIONATE', label: '열정 응원러' } 형태로 정의하고, API에는 value만 사용.

src/shared/constants/query-key.ts (1)

9-10: 키 네이밍 컨벤션 통일 제안

usersNumCount 등 기존 키는 camelCase를 사용합니다. 일관성을 위해 다음과 같이 권장합니다.

-  EDIT_PROFILE: () => [...USER_KEY.ALL, 'edit'] as const,
-  MATCH_CONDITION: () => [...USER_KEY.ALL, 'match_condition'] as const,
+  EDIT_PROFILE: () => [...USER_KEY.ALL, 'edit'] as const,
+  MATCH_CONDITION: () => [...USER_KEY.ALL, 'matchCondition'] as const,
src/pages/edit-profile/schema/EditProfileSchema.ts (1)

1-7: 스키마 공통화로 모듈 의존 축소 제안

@pages/sign-up/...에 의존하면 페이지 간 결합도가 올라갑니다. 공통 스키마(예: @shared/schemas/user.ts)로 이동해 회원가입/프로필수정이 함께 참조하도록 리팩터링을 고려하세요.

src/shared/apis/user/user-queries.ts (1)

25-25: 제네릭 중복 지정 제거로 간결화

queryOptions<...>에서 이미 응답 타입을 고정했으므로 get 호출의 제네릭은 생략 가능합니다.

아래처럼 단순화하세요:

-      queryFn: () => get<getMatchConditionResponse>(END_POINT.MATCH_CONDITION),
+      queryFn: () => get(END_POINT.MATCH_CONDITION),
src/shared/types/user-types.ts (1)

35-43: 문서화된 HTTP 메서드와 실제 사용 메서드 불일치

주석에는 둘 다 post로 표기되어 있지만, 코드에서는 프로필 수정은 PUT, 매칭 조건 수정은 PATCH를 사용합니다. 실제 서버 스펙에 맞게 주석을 정정하거나, 필요시 메서드를 맞춰주세요.

권장 변경(주석 정정):

 /**
  * 사용자 정보 수정
- * post
+ * put
  * /v2/users/info
  */

 /**
  * 매칭 조건 수정
- * post
+ * patch
  * /v2/users/match-condition
  */

Also applies to: 58-61

src/shared/apis/user/user-mutations.ts (1)

45-47: 불필요한 async 키워드 제거

onSuccess에서 await를 사용하지 않으므로 async는 제거하세요. 작은 정리지만 가독성이 좋아집니다.

-      onSuccess: async () => {
-        queryClient.invalidateQueries({ queryKey: USER_KEY.ALL });
-      },
+      onSuccess: () => {
+        queryClient.invalidateQueries({ queryKey: USER_KEY.ALL });
+      },
src/pages/edit-profile/edit-profile.tsx (2)

33-34: 닉네임/소개 수정 버튼의 비활성화 조건 보완

react-hook-formisSubmittinghandleSubmit 기반 서브밋에만 반응합니다. 현재는 trigger + 직접 mutate 호출이라 중복 클릭 방지가 되지 않을 수 있습니다. 프로필 수정 뮤테이션의 isPending을 사용해 버튼을 제어하세요.

-  const { mutate: editProfile } = useMutation(userMutations.EDIT_PROFILE());
+  const { mutate: editProfile, isPending: isEditProfilePending } =
+    useMutation(userMutations.EDIT_PROFILE());

   <Button
     type="button"
     label="수정"
     onClick={submitNickname}
-    disabled={!!errors.nickname || nicknameVal.trim().length === 0 || isSubmitting}
+    disabled={!!errors.nickname || nicknameVal.trim().length === 0 || isEditProfilePending}
     className="cap_14_sb mt-[0.8rem] w-auto px-[1.6rem] py-[0.6rem]"
   />

   <Button
     type="button"
     label="수정"
     onClick={submitInformation}
-    disabled={!!errors.information || informationVal.trim().length === 0 || isSubmitting}
+    disabled={
+      !!errors.information || informationVal.trim().length === 0 || isEditProfilePending
+    }
     className="cap_14_sb mt-[0.8rem] w-auto px-[1.6rem] py-[0.6rem]"
   />

Also applies to: 121-123, 150-152


54-55: 서버 필드 키 값 확인 필요(닉네임/소개)

field: '닉네임', field: '소개'처럼 한글 라벨을 그대로 전송합니다. BE가 기대하는 키(예: 'nickname', 'introduction' 등 코드 값)와 일치하는지 반드시 확인하세요. 불일치 시 400/무시될 수 있습니다.

필요하시다면 필드 키 매핑 유틸(라벨↔코드)을 만들어 드리겠습니다.

Also applies to: 60-61

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9d8627b and 2ab45b9.

📒 Files selected for processing (9)
  • src/pages/edit-profile/constants/edit-profile.ts (1 hunks)
  • src/pages/edit-profile/edit-profile.tsx (3 hunks)
  • src/pages/edit-profile/schema/EditProfileSchema.ts (1 hunks)
  • src/shared/apis/base/http.ts (1 hunks)
  • src/shared/apis/user/user-mutations.ts (2 hunks)
  • src/shared/apis/user/user-queries.ts (2 hunks)
  • src/shared/constants/api.ts (1 hunks)
  • src/shared/constants/query-key.ts (1 hunks)
  • src/shared/types/user-types.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: heesunee
PR: MATEBALL/MATEBALL-CLIENT#78
File: src/pages/sign-up/utils/age-calculate.ts:1-4
Timestamp: 2025-07-09T09:08:46.371Z
Learning: heesunee는 나이 계산 시 한국식 나이 시스템을 사용하므로, 정확한 생일 기반 계산보다는 출생연도 기준의 간단한 계산 방식을 선호합니다.
🧬 Code graph analysis (6)
src/pages/edit-profile/schema/EditProfileSchema.ts (1)
src/pages/sign-up/schema/validation-schema.ts (1)
  • NicknameSchema (14-43)
src/shared/apis/base/http.ts (1)
src/shared/apis/base/instance.ts (1)
  • instance (8-14)
src/shared/types/user-types.ts (1)
src/shared/types/match-types.ts (1)
  • postMatchConditionRequest (166-171)
src/shared/apis/user/user-queries.ts (4)
src/shared/types/user-types.ts (1)
  • getMatchConditionResponse (50-55)
src/shared/constants/query-key.ts (1)
  • USER_KEY (2-11)
src/shared/apis/base/http.ts (1)
  • get (3-5)
src/shared/constants/api.ts (1)
  • END_POINT (3-41)
src/shared/apis/user/user-mutations.ts (5)
src/shared/types/base-types.ts (1)
  • responseTypes (7-10)
src/shared/types/user-types.ts (2)
  • postEditProfileRequest (40-43)
  • postMatchConditionRequest (62-67)
src/shared/constants/query-key.ts (1)
  • USER_KEY (2-11)
src/shared/apis/base/http.ts (2)
  • put (15-17)
  • patch (11-13)
src/shared/constants/api.ts (1)
  • END_POINT (3-41)
src/pages/edit-profile/edit-profile.tsx (7)
src/shared/apis/user/user-queries.ts (1)
  • userQueries (7-27)
src/shared/apis/user/user-mutations.ts (1)
  • userMutations (14-59)
src/pages/edit-profile/schema/EditProfileSchema.ts (2)
  • EditProfileValues (9-9)
  • EditProfileSchema (4-7)
src/pages/onboarding/constants/onboarding.ts (3)
  • NO_TEAM_OPTION (26-26)
  • TEAMS (13-24)
  • GENDER (48-63)
src/pages/sign-up/constants/validation.ts (2)
  • NICKNAME_PLACEHOLDER (21-21)
  • INFORMATION_PLACEHOLDER (25-26)
src/pages/sign-up/constants/NOTICE.ts (2)
  • NICKNAME_RULE_MESSAGE (9-9)
  • INFORMATION_RULE_MESSAGE (17-17)
src/pages/edit-profile/constants/edit-profile.ts (1)
  • PROFILE_VIEWING_STYLE (3-16)
🔇 Additional comments (4)
src/shared/apis/base/http.ts (1)

15-17: PUT 래퍼 추가 좋습니다

기존 get/post/patch 패턴과 일관되고, res.data 추출 형태도 동일합니다.

src/pages/edit-profile/schema/EditProfileSchema.ts (1)

4-9: Sign-up 스키마 재사용 접근 좋습니다

중복을 줄이면서 동일 검증 규칙을 유지합니다.

src/shared/apis/user/user-queries.ts (1)

22-26: MATCH_CONDITION 쿼리 추가 LGTM

키/엔드포인트/타입 지정이 일관되고, 베이스 get 래퍼 사용도 적절합니다.

src/shared/apis/user/user-mutations.ts (1)

53-58: PATCH가 서버 스펙과 일치하는지 확인 필요

주석과 상수명은 과거 POST_* 컨벤션을 따르고 있어 혼동 소지가 있습니다. 현재 /v2/users/match-conditionPATCH가 맞는지 BE 스펙을 재확인해주세요. 필요 시 메서드/주석/상수명(예: MATCH_CONDITION 유지 or PATCH_MATCH_CONDITION로 변경)을 일치시켜 주세요.

const [gender, setGender] = useState<string | undefined>(undefined);
const [mateTeam, setMateTeam] = useState<string | undefined>(undefined);
const [viewStyle, setViewStyle] = useState<string | undefined>(undefined);
const [isSubmit, setIsSubmit] = useState(false);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

저장 버튼이 한 번 클릭 후 영구 비활성화되는 버그

isSubmittrue로 바꾼 뒤 다시 false로 복구하지 않아 버튼이 계속 비활성화됩니다. 뮤테이션의 isPending을 사용해 상태를 추적하거나 onSettled에서 복구하세요. 아래는 isPending을 쓰는 간단한 수정안입니다.

-  const [isSubmit, setIsSubmit] = useState(false);
+  // isSubmit 로컬 상태 대신 뮤테이션 pending 상태 사용

-  const { mutate: editMatchCondition } = useMutation(userMutations.EDIT_MATCH_CONDITION());
+  const { mutate: editMatchCondition, isPending: isEditMatchPending } =
+    useMutation(userMutations.EDIT_MATCH_CONDITION());

-  const isSubmitDisabled = !isMatchDirty || isSubmit;
+  const isSubmitDisabled = !isMatchDirty || isEditMatchPending;

   const handleSaveClick = () => {
     if (!isMatchDirty) return;
-    setIsSubmit(true);
-
-    editMatchCondition({
-      team: teamValue,
-      genderPreference: genderValue,
-      style: viewStyleValue,
-      teamAllowed: teamValue === NO_TEAM_OPTION ? null : mateTeamValue || null,
-    });
+    editMatchCondition(
+      {
+        team: teamValue,
+        genderPreference: genderValue,
+        style: viewStyleValue,
+        teamAllowed: teamValue === NO_TEAM_OPTION ? null : mateTeamValue || null,
+      }
+      // 필요 시 onError/onSuccess에서 토스트 노출 등 처리
+    );
   };

Also applies to: 33-35, 81-82, 83-93

🤖 Prompt for AI Agents
In src/pages/edit-profile/edit-profile.tsx around lines 31 (and related 33-35,
81-82, 83-93), the local state isSubmit is set true on submit but never reset,
causing the save button to remain disabled; replace the manual boolean toggle
with the mutation's isPending (or at minimum call setIsSubmit(false) in the
mutation's onSettled callback) so the disabled state reflects the actual request
lifecycle — update button/disabled checks to use mutation.isPending (or
setIsSubmit(false) in onSettled), remove any permanent setIsSubmit(true) paths,
and ensure all submit-related branches (lines noted) use the same
lifecycle-driven flag.

Comment on lines +53 to +58
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 }),
}),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

EDIT_MATCH_CONDITION: 반환 타입/캐시 무효화 보완

  • mutationOptionsTData가 요청 바디 타입(postMatchConditionRequest)로 지정되어 있어 타입 안정성이 떨어집니다. 다른 뮤테이션과 동일하게 responseTypes로 맞추는 것을 권장합니다.
  • 성공 시 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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 }),
}),
EDIT_MATCH_CONDITION: () =>
mutationOptions<responseTypes, Error, postMatchConditionRequest>({
mutationKey: USER_KEY.MATCH_CONDITION(),
mutationFn: ({ team, teamAllowed, style, genderPreference }) =>
patch<responseTypes>(END_POINT.MATCH_CONDITION, {
team,
teamAllowed,
style,
genderPreference,
}),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: USER_KEY.MATCH_CONDITION() });
},
}),
🤖 Prompt for AI Agents
In src/shared/apis/user/user-mutations.ts around lines 53 to 58, change the
mutation generic TData from the request body type to the API response type
(e.g., mutationOptions<postMatchConditionResponse, Error,
postMatchConditionRequest>) and add an onSuccess handler that invalidates the
MATCH_CONDITION cache (e.g., call
queryClient.invalidateQueries(USER_KEY.MATCH_CONDITION()) or equivalent) so the
UI refreshes after a successful edit.

Comment on lines +62 to +67
export interface postMatchConditionRequest {
team: string;
teamAllowed: string | null;
style: string;
genderPreference: string;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

postMatchConditionRequest 타입 중복 정의 제거 (단일 소스 유지)

src/shared/types/match-types.ts에도 동일한 postMatchConditionRequest가 존재합니다. 타입이 분산되면 향후 드리프트 위험이 큽니다. user-types.ts에서 재정의 대신 리익스포트를 권장합니다.

아래처럼 중복 인터페이스를 제거하고 리익스포트로 대체하세요:

- export interface postMatchConditionRequest {
-   team: string;
-   teamAllowed: string | null;
-   style: string;
-   genderPreference: string;
- }
+export type { postMatchConditionRequest } from '@/shared/types/match-types';

추가로, 현재 src/shared/apis/user/user-mutations.tspostMatchConditionRequestuser-types에서 import하고 있으므로, 위와 같이 리익스포트하면 기존 import 경로를 유지하면서 중복만 제거됩니다.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export interface postMatchConditionRequest {
team: string;
teamAllowed: string | null;
style: string;
genderPreference: string;
}
export type { postMatchConditionRequest } from '@/shared/types/match-types';
🤖 Prompt for AI Agents
In src/shared/types/user-types.ts around lines 62 to 67, remove the duplicate
postMatchConditionRequest interface and instead re-export the single
authoritative type from src/shared/types/match-types.ts; delete the interface
block here, add a re-export statement that forwards postMatchConditionRequest
from match-types, and ensure the module still exports whatever else it needs so
existing imports (e.g., src/shared/apis/user/user-mutations.ts) continue to work
without changing their import paths.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/shared/apis/user/user-mutations.ts (1)

58-63: 반환 타입 오적용 + 캐시 무효화 누락 (이전 리뷰와 동일 이슈)

뮤테이션의 TData를 요청 바디 타입으로 지정해 타입 안정성이 깨집니다. 또한 성공 시 MATCH_CONDITION 쿼리를 무효화해야 UI가 최신 상태로 갱신됩니다.

-  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() });
+      },
+    }),
🧹 Nitpick comments (3)
src/shared/constants/query-key.ts (1)

10-11: 쿼리 키 네이밍 일관성 제안 (match_condition)

USER_KEY 내 다른 토큰들은 대부분 하이픈/언더스코어 없이 소문자 또는 카멜케이스입니다. "match_condition"만 언더스코어를 사용해 일관성이 깨집니다. 캐시 키 가독성을 위해 카멜케이스로 맞추는 것을 권장합니다.

-  MATCH_CONDITION: () => [...USER_KEY.ALL, 'match_condition'] as const,
+  MATCH_CONDITION: () => [...USER_KEY.ALL, 'matchCondition'] as const,

기존에 이미 발급된 캐시 키가 있다면 병행 배포 시 캐시 미스가 발생할 수 있으니, 관련 쿼리/뮤테이션의 key 문자열 동기화 여부를 확인해주세요.

src/shared/apis/user/user-queries.ts (1)

16-21: USER_INFO 쿼리의 v1 전환 — 타입/계약 호환성 점검 필요

USER_INFO 조회가 v2(/v2/users/info)에서 v1(/v1/users/info)로 변경되었습니다. getUserInfoResponse 타입이 v1 스키마와 일치하는지, 그리고 쓰기 경로(등록/수정)는 v2를 사용 중인 점이 의도된 분리인지 확인해주세요.

읽기/쓰기를 동일 버전으로 통일하거나, 타입을 버전별로 분리하면 유지보수성이 높아집니다.

src/shared/apis/user/user-mutations.ts (1)

45-56: 전체 리로드 제거하고 캐시 무효화만으로 갱신하세요

window.location.reload()는 UX·성능에 불리합니다. invalidateQueriesawait로 보장하면 전체 리로드 없이도 반영됩니다. 또한 엔드포인트 상수명을 PUT에 맞춰 정리하세요.

-      mutationFn: ({ field, value }) => put(END_POINT.POST_EDIT_PROFILE, { field, value }),
-      onSuccess: async () => {
-        queryClient.invalidateQueries({ queryKey: USER_KEY.ALL });
-        window.location.reload();
-      },
+      mutationFn: ({ field, value }) => put(END_POINT.PUT_EDIT_PROFILE, { field, value }),
+      onSuccess: async () => {
+        await queryClient.invalidateQueries({ queryKey: USER_KEY.ALL });
+      },

과거 학습에 따르면 heesunee는 출생연도 기반(한국식) 나이 계산을 선호합니다. fieldbirthYear일 때, 프런트의 나이 표시/검증 로직과 동기화되는지 한번 점검해주세요.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2ab45b9 and 73b055f.

📒 Files selected for processing (7)
  • src/pages/edit-profile/edit-profile.tsx (3 hunks)
  • src/pages/edit-profile/schema/EditProfileSchema.ts (1 hunks)
  • src/shared/apis/user/user-mutations.ts (2 hunks)
  • src/shared/apis/user/user-queries.ts (2 hunks)
  • src/shared/constants/api.ts (1 hunks)
  • src/shared/constants/query-key.ts (1 hunks)
  • src/shared/types/user-types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/shared/types/user-types.ts
  • src/pages/edit-profile/schema/EditProfileSchema.ts
  • src/pages/edit-profile/edit-profile.tsx
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: heesunee
PR: MATEBALL/MATEBALL-CLIENT#78
File: src/pages/sign-up/utils/age-calculate.ts:1-4
Timestamp: 2025-07-09T09:08:46.371Z
Learning: heesunee는 나이 계산 시 한국식 나이 시스템을 사용하므로, 정확한 생일 기반 계산보다는 출생연도 기준의 간단한 계산 방식을 선호합니다.
🧬 Code graph analysis (2)
src/shared/apis/user/user-queries.ts (4)
src/shared/apis/base/http.ts (1)
  • get (3-5)
src/shared/constants/api.ts (1)
  • END_POINT (3-43)
src/shared/types/user-types.ts (1)
  • getMatchConditionResponse (52-57)
src/shared/constants/query-key.ts (1)
  • USER_KEY (2-12)
src/shared/apis/user/user-mutations.ts (5)
src/shared/types/base-types.ts (1)
  • responseTypes (7-10)
src/shared/types/user-types.ts (2)
  • postEditProfileRequest (42-45)
  • postMatchConditionRequest (64-69)
src/shared/constants/query-key.ts (1)
  • USER_KEY (2-12)
src/shared/apis/base/http.ts (2)
  • put (15-17)
  • patch (11-13)
src/shared/constants/api.ts (1)
  • END_POINT (3-43)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: chromatic
🔇 Additional comments (4)
src/shared/constants/api.ts (1)

15-18: POST_EDIT_PROFILE 네이밍 및 API 버전 혼재 정리 필요

  • POST_EDIT_PROFILE이 실제로 PUT 호출에 사용되고 있어 네이밍과 HTTP 메서드가 불일치합니다. PUT_EDIT_PROFILE로 변경을 권장합니다.
  • GET_USER_INFO는 v1(/v1/users/info), PUT_EDIT_PROFILE는 v2(/v2/users/info) 경로를 사용 중입니다. 버전별 요청/응답 스키마 차이가 있는지 확인 후 일관성 있게 통일하거나 명확히 분리해 주세요.
-  POST_EDIT_PROFILE: '/v2/users/info',
+  PUT_EDIT_PROFILE: '/v2/users/info',
  • getUserInfoResponsepostEditProfileRequest 타입이 각각의 버전에 맞게 정의되어 있는지 백엔드 계약과 일치하는지 검증 부탁드립니다.
src/shared/apis/user/user-queries.ts (2)

5-5: 타입 임포트 추가 LGTM

추가된 getMatchConditionResponse 임포트 적절합니다.


22-26: MATCH_CONDITION 쿼리 추가 LGTM

키/엔드포인트/타입 매핑이 올바릅니다. 이후 뮤테이션 성공 시 이 키를 무효화하면 UI가 즉시 갱신됩니다.

src/shared/apis/user/user-mutations.ts (1)

9-14: 타입 임포트 추가 LGTM

요청 바디 타입 분리가 명확합니다. 위 코멘트대로 EDIT_MATCH_CONDITIONTData만 응답 타입으로 정정하면 일관성이 완성됩니다.

@heesunee heesunee merged commit 492cbea into develop Aug 31, 2025
7 checks passed
@heesunee heesunee deleted the feat/#325/edit-profile-api branch August 31, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat new feature 희선

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 프로필 수정 api를 연결합니다.

1 participant