-
Notifications
You must be signed in to change notification settings - Fork 0
정산 참여(join) 플로우 구현 + 프로필 컴포넌트 리팩토링 #28
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
eb1f3fd
refactor: MemberProfile, MemberProfileImage를 Profile, ProfileImage로 통합
yoouyeon 239d1ea
fix: 실제 백엔드 구현에 맞게 getUserInfo, getGroupHeader API 엔드포인트 수정
yoouyeon 238902a
feat: MemberProfile 타입 정의와 member API 추가
yoouyeon fcd5b20
feat: 정산 참여(join) 플로우 구현
yoouyeon 6e7e60a
chore: 정산 참여 플로우 관련 MSW 핸들러 추가
yoouyeon 1477a0a
fix: 코드래빗 리뷰 반영
yoouyeon 691a8c3
docs: 로그인 리다이렉트 관련 후속 이슈를 주석으로 남김
yoouyeon 60db662
merge: Merge branch 'develop' into feat/MD-22
yoouyeon 7c131c9
fix: MemberProfileImage를 ProfileImage로 변경
yoouyeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import axiosInstance from '@/shared/api/axios'; | ||
|
|
||
| // 참여자 선택 api (로그인한 참여자가 정산에 참여하도록 프로필 설정) | ||
| export const assignMember = async ( | ||
| settlementCode: string, | ||
| memberId: number | ||
| ): Promise<void> => { | ||
| await axiosInstance.post( | ||
| `/groups/${settlementCode}/members/assign`, | ||
| { | ||
| memberId, | ||
| }, | ||
| { useMock: true } | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import axiosInstance from '@/shared/api/axios'; | ||
| import { MemberProfile, MemberProfileData } from '../model/member.type'; | ||
|
|
||
| // TODO : 기존 groupToken들을 사용하는 방식을 settlementCode를 사용하는 방식으로 변경해야 함. | ||
| // 모임원 조회 API - 정산 참여자 프로필 조회 | ||
| export const getProfiles = async ( | ||
| settlementCode: string | ||
| ): Promise<MemberProfile[]> => { | ||
| const response = await axiosInstance.get<MemberProfileData>( | ||
| `/groups/${settlementCode}/members`, | ||
| { useMock: true } | ||
| ); | ||
| return response.data.members; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
| import { assignMember } from '@/entities/member/api/assignMember'; | ||
|
|
||
| const useAssignMember = (groupToken: string) => { | ||
| const queryClient = useQueryClient(); | ||
| return useMutation({ | ||
| mutationFn: (memberId: number) => assignMember(groupToken, memberId), | ||
| onSuccess: () => { | ||
| queryClient.removeQueries({ queryKey: ['profiles', groupToken] }); | ||
| }, | ||
| }); | ||
| }; | ||
|
|
||
| export default useAssignMember; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // 정산 상세 페이지 전 거치는 로더 | ||
| // TODO : 기존 groupToken들을 사용하는 방식을 settlementCode를 사용하는 방식으로 변경했음. 동작 확인 필요함. | ||
|
|
||
| import { getUserInfo } from '@/entities/auth/api/auth'; | ||
| import { getGroupHeader } from '@/entities/group/api/group'; | ||
| import { getProfiles } from '@/entities/member/api/getProfiles'; | ||
| import { queryClient } from '@/shared/api/queryClient'; | ||
| import { ROUTE } from '@/shared/config/route'; | ||
| import { BoundaryError } from '@/shared/types/error.type'; | ||
| import { isAxiosError } from 'axios'; | ||
| import { LoaderFunctionArgs, redirect } from 'react-router'; | ||
|
|
||
| async function expenseDetailLoader({ params }: LoaderFunctionArgs) { | ||
| // TODO: groupToken → settlementCode 마이그레이션 시 파라미터 이름 변경 필요 | ||
| const { groupToken } = params; | ||
|
|
||
| if (!groupToken) return redirect(ROUTE.home); | ||
|
|
||
| try { | ||
| // 1. 로그인 여부 확인 | ||
| // TODO: getUserInfo 401 발생 시 axiosInstance 인터셉터가 window.location.href로 처리해 returnUrl이 무시됨. 인터셉터를 React Router redirect 방식으로 교체 필요. (https://moddo2.atlassian.net/browse/MD-25) | ||
| const user = await queryClient.ensureQueryData({ | ||
| queryKey: ['userInfo'], | ||
| queryFn: getUserInfo, | ||
| }); | ||
| // TODO: 로그인 페이지에서 성공 후 returnUrl 처리 필요함 | ||
| if (!user) { | ||
| const returnUrl = encodeURIComponent(`/expense-detail/${groupToken}`); | ||
| return redirect(`/login?returnUrl=${returnUrl}`); | ||
| } | ||
|
|
||
| // 2. 프로필 선택 여부 확인 | ||
| const profiles = await queryClient.ensureQueryData({ | ||
| queryKey: ['profiles', groupToken], | ||
| queryFn: () => getProfiles(groupToken), | ||
| }); | ||
| const myProfile = | ||
| profiles.find((profile) => profile.userId === user.id) ?? null; | ||
| if (!myProfile) return redirect(`/join/${groupToken}`); | ||
|
|
||
| const groupData = await queryClient.ensureQueryData({ | ||
| queryKey: ['groupHeader', groupToken], | ||
| queryFn: () => getGroupHeader(groupToken), | ||
| }); | ||
|
|
||
| return { groupToken, groupData, myProfile }; | ||
| } catch (error: unknown) { | ||
| if (isAxiosError(error)) { | ||
| // CHECK - 문서에는 401 에러로 되어있지만 실제로는 500 에러가 발생함 | ||
| if (error.response?.status === 401) { | ||
| throw new BoundaryError({ | ||
| title: '접근 권한이 없어요', | ||
| description: '참여한 모임의 정산만 확인할 수 있어요.', | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| // 그 외에는 그대로 전달 | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| export default expenseDetailLoader; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.