-
Notifications
You must be signed in to change notification settings - Fork 1
feat: mypage api 연동 (badge history, level) #98
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 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
616a8b1
feat: my-level api 연동
d0422 56c48db
feat: unique util 추가
d0422 0c593ce
feat: 뱃지 지역별 unique처리 및 기존 MAPPER 객체 사용하도록 변경
d0422 1d62eb0
chore: MAPPER객체, REVERSE MAPPER객체 추가
d0422 baa0d1e
feat: MyBadge api연동
d0422 fad4db9
feat: loading view 추가
d0422 8606210
feat: 뱃지 제목 상세 지역으로 변경
d0422 96c7581
fix: Trip 추가시 navigation대신 뒤로가기 처리하여 네비게이팅 오류 해결
d0422 96352b6
chore: bottom sheet, Badge history Suspense 적용
d0422 27822a6
chore: 일정 -> 나의일정으로 문구 변경
d0422 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
38 changes: 38 additions & 0 deletions
38
packages/react-native/src/apis/queries/mypage/useBadgeHistoryQuery.ts
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,38 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import useAuthAxios from '@/apis/useAuthAxios'; | ||
import { badgePath } from '@/components/common/Badge'; | ||
import { BadgeAcquisition } from '@/constants/BADGE_ACQUISITION'; | ||
import { City, Region, REVERSE_BADGE_MAPPER } from '@/constants/CITY'; | ||
import QUERY_KEYS from '@/constants/QUERY_KEYS'; | ||
import { ServerResponse } from '@/types/response'; | ||
|
||
interface BadgeHistoryResponse { | ||
region: Region; | ||
city: City; | ||
acquisitionType: BadgeAcquisition; | ||
createdAt: string; | ||
} | ||
|
||
export default function useBadgeHistoryQuery({ | ||
region, | ||
}: { | ||
region: keyof typeof badgePath; | ||
}) { | ||
const badgeRegions = REVERSE_BADGE_MAPPER[region]; | ||
const params = Array.isArray(badgeRegions) | ||
? badgeRegions.join(',') | ||
: badgeRegions; | ||
const authAxios = useAuthAxios(); | ||
|
||
const getBadgeHistory = async () => { | ||
const result = await authAxios.get<ServerResponse<BadgeHistoryResponse[]>>( | ||
`/api/user/badge/acquisition?regions=${params}`, | ||
); | ||
return result.data.result; | ||
}; | ||
|
||
return useQuery({ | ||
queryKey: [QUERY_KEYS.BADGE_HISTORY, region], | ||
queryFn: getBadgeHistory, | ||
}); | ||
} |
50 changes: 5 additions & 45 deletions
50
packages/react-native/src/apis/queries/mypage/useMyBadgeQuery.ts
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
23 changes: 23 additions & 0 deletions
23
packages/react-native/src/apis/queries/mypage/useMyLevelQuery.ts
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,23 @@ | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
import useAuthAxios from '@/apis/useAuthAxios'; | ||
import QUERY_KEYS from '@/constants/QUERY_KEYS'; | ||
import { ServerResponse } from '@/types/response'; | ||
|
||
interface LevelResponse { | ||
profileLevel: string; | ||
description: string; | ||
} | ||
|
||
export default function useMyLevelQuery() { | ||
const authAxios = useAuthAxios(); | ||
const getMyLevel = async () => { | ||
const result = | ||
await authAxios.get<ServerResponse<LevelResponse>>('/api/user/level'); | ||
return result.data.result; | ||
}; | ||
|
||
return useSuspenseQuery({ | ||
queryKey: [QUERY_KEYS.MY_LEVEL], | ||
queryFn: getMyLevel, | ||
}); | ||
} |
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
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,9 @@ | ||
function unique<T extends object>(array: T[], key: keyof T) { | ||
return array.reduce<T[]>((uniq, item) => { | ||
return uniq.some((element) => element[key] === item[key]) | ||
? uniq | ||
: [...uniq, item]; | ||
}, []); | ||
} | ||
|
||
export default unique; |
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.
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.
이 부분은 컴포넌트로 만들 수 없나요?? 추가로 Suspense 적용은 어려울까요??
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.
반영하였습니다! 96352b6