Skip to content

Commit 4a8aa9b

Browse files
authored
Merge branch 'develop' into feat/#194/feed-cd-api
2 parents 18dfa1e + 7290a49 commit 4a8aa9b

File tree

33 files changed

+745
-474
lines changed

33 files changed

+745
-474
lines changed

src/App.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { useLocation } from 'react-router-dom'
33

44
import styled from 'styled-components'
55

6-
import { ToastProvider } from '@app/providers'
76
import { AppRoutes } from '@app/routes/routes'
87

98
import { routesConfig, type RouteConfig } from '@shared/config/routesConfig'
@@ -143,15 +142,13 @@ const App = () => {
143142
$layoutWidth={LAYOUT_WIDTH}
144143
$layoutBottomGap={LAYOUT_BOTTOM_GAP}
145144
>
146-
<ToastProvider>
147-
<AppRoutes />
148-
{isNavVisible && (
149-
<NavContainer $layoutWidth={LAYOUT_WIDTH} $layoutBottomGap={LAYOUT_BOTTOM_GAP}>
150-
<NavBar />
151-
</NavContainer>
152-
)}
153-
<GlobalErrorModal />
154-
</ToastProvider>
145+
<AppRoutes />
146+
{isNavVisible && (
147+
<NavContainer $layoutWidth={LAYOUT_WIDTH} $layoutBottomGap={LAYOUT_BOTTOM_GAP}>
148+
<NavBar />
149+
</NavContainer>
150+
)}
151+
<GlobalErrorModal />
155152
</MainLayout>
156153
</RootWrapper>
157154
)

src/app/providers/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { ChatProvider } from '@/app/providers/ChatProvider'
2-
1+
import { ChatProvider } from './ChatProvider'
32
import { default as PlayerProvider } from './PlayerProvider'
43
import QueryProvider from './QueryProvider'
54
import ThemeProvider from './ThemeProvider'
58.3 KB
Loading
-5.78 KB
Loading
95.1 KB
Loading

src/entities/playlist/types/playlist.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface CdBasicInfo {
77
playlistId: number
88
playlistName: string
99
creatorNickname?: string
10+
creatorShareCode?: string
1011
genre: string
1112
isPublic: boolean
1213
isLiked?: boolean

src/entities/user/constants/user.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
export const PROFILE_LIMITS = {
22
MAX_FILE_SIZE: 5 * 1024 * 1024, // 5mb
3-
NICKNAME: 10,
3+
NICKNAME: { MIN: 2, MAX: 10 },
44
SHARE_CODE: { MIN: 5, MAX: 12 },
55
BIO: 25,
66
KEYWORDS: 3,
77
} as const
88

99
export const PROFILE_ERROR_MESSAGES = {
1010
image: `${PROFILE_LIMITS.MAX_FILE_SIZE / (1024 * 1024)}MB 이하의 파일만 업로드 가능해요`,
11-
nickname: `${PROFILE_LIMITS.NICKNAME}자 이내로 입력 가능해요`,
11+
nickname: `${PROFILE_LIMITS.NICKNAME.MIN}-${PROFILE_LIMITS.NICKNAME.MAX}자로 입력해 주세요`,
1212
shareCode: {
13-
isInvalid: `${PROFILE_LIMITS.SHARE_CODE.MIN}~${PROFILE_LIMITS.SHARE_CODE.MAX}자의 영문자, 숫자, 언더바(_)만 입력할 수 있어요`,
13+
isTooShort: `${PROFILE_LIMITS.SHARE_CODE.MIN}자 이상 입력해 주세요`,
14+
isOnlyUnderscore: `_만 사용할 수는 없어요`,
15+
isInvalid: `영문, 숫자, _만 사용할 수 있어요`,
1416
isDuplicate: '이미 사용 중인 아이디예요',
1517
},
16-
bio: `${PROFILE_LIMITS.BIO}자 이내로 입력 가능해요`,
18+
bio: `${PROFILE_LIMITS.BIO}자 이내로 입력해 주세요`,
1719
} as const
1820

1921
export const PROFILE_KEYWORDS_LIST = [

src/features/follow/api/follow.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import type {
22
FollowListResponse,
3-
FollowSortType,
3+
FollowParams,
44
FollowStatusResponse,
55
} from '@/features/follow/types/follow'
66
import { api } from '@/shared/api/httpClient'
77

8-
export const postFollow = (userId: string) => {
9-
return api.post(`/main/follow/${userId}`)
8+
export const postFollow = (shareCode: string) => {
9+
return api.post(`/main/follow/${shareCode}`)
1010
}
1111

12-
export const deleteFollow = (userId: string) => {
13-
return api.delete(`/main/follow/${userId}`)
12+
export const deleteFollow = (shareCode: string) => {
13+
return api.delete(`/main/follow/${shareCode}`)
1414
}
1515

16-
export const getFollowStatus = (userId: string) => {
17-
return api.get<FollowStatusResponse>(`/main/follow/${userId}`)
16+
export const getFollowStatus = (shareCode: string) => {
17+
return api.get<FollowStatusResponse>(`/main/follow/${shareCode}`)
1818
}
1919

20-
export const getFollowingList = (userId: string, sort?: FollowSortType) => {
21-
return api.get<FollowListResponse>(`/main/follow/following/${userId}`, {
22-
params: { sort: sort }, // Default: LATEST
20+
export const getFollowingList = (shareCode: string, params?: FollowParams) => {
21+
return api.get<FollowListResponse>(`/main/follow/following/${shareCode}`, {
22+
params,
2323
})
2424
}
2525

26-
export const getFollowerList = (userId: string, sort?: FollowSortType) => {
27-
return api.get<FollowListResponse>(`/main/follow/follower/${userId}`, {
28-
params: { sort: sort }, // Default: LATEST
26+
export const getFollowerList = (shareCode: string, params?: FollowParams) => {
27+
return api.get<FollowListResponse>(`/main/follow/follower/${shareCode}`, {
28+
params,
2929
})
3030
}

src/features/follow/model/useFollow.ts

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { useMutation, useQueryClient } from '@tanstack/react-query'
1+
import {
2+
useInfiniteQuery,
3+
useMutation,
4+
useQueryClient,
5+
type InfiniteData,
6+
} from '@tanstack/react-query'
27
import { useQuery } from '@tanstack/react-query'
38

49
import {
@@ -8,15 +13,15 @@ import {
813
getFollowingList,
914
getFollowerList,
1015
} from '@/features/follow/api/follow'
11-
import type { FollowSortType } from '@/features/follow/types/follow'
16+
import type { FollowListResponse, FollowSortType } from '@/features/follow/types/follow'
1217

13-
const useFollow = (shareCode: string, initialIsFollowing?: boolean) => {
18+
const useFollow = (shareCode: string, initialIsFollowing?: boolean, enabled = true) => {
1419
const queryClient = useQueryClient()
1520

1621
const { data } = useQuery({
1722
queryKey: ['followStatus', shareCode],
1823
queryFn: () => getFollowStatus(shareCode),
19-
enabled: !!shareCode,
24+
enabled: !!shareCode && enabled,
2025
initialData: initialIsFollowing !== undefined ? { isFollowing: initialIsFollowing } : undefined,
2126
})
2227

@@ -73,18 +78,34 @@ const useFollow = (shareCode: string, initialIsFollowing?: boolean) => {
7378

7479
export default useFollow
7580

76-
export const useFollowerList = (shareCode: string, sort?: FollowSortType) => {
77-
return useQuery({
78-
queryKey: ['followerList', shareCode, sort],
79-
queryFn: () => getFollowerList(shareCode, sort),
80-
enabled: !!shareCode,
81-
})
82-
}
81+
export const useFollowList = (
82+
type: 'FOLLOWERS' | 'FOLLOWING',
83+
shareCode: string,
84+
sort: FollowSortType = 'LATEST'
85+
) => {
86+
const isFollower = type === 'FOLLOWERS'
87+
const queryKey = isFollower ? 'followerList' : 'followingList'
88+
const fetchFn = isFollower ? getFollowerList : getFollowingList
8389

84-
export const useFollowingList = (shareCode: string, sort?: FollowSortType) => {
85-
return useQuery({
86-
queryKey: ['followingList', shareCode, sort],
87-
queryFn: () => getFollowingList(shareCode, sort),
90+
return useInfiniteQuery<
91+
FollowListResponse,
92+
Error,
93+
InfiniteData<FollowListResponse>,
94+
string[],
95+
number | undefined
96+
>({
97+
queryKey: [queryKey, shareCode, sort],
98+
queryFn: ({ pageParam }) =>
99+
fetchFn(shareCode, {
100+
cursor: pageParam,
101+
limit: 10,
102+
sort,
103+
}),
104+
initialPageParam: undefined,
88105
enabled: !!shareCode,
106+
getNextPageParam: (lastPage) => {
107+
if (!lastPage.hasNext) return undefined
108+
return lastPage.nextCursor
109+
},
89110
})
90111
}

src/features/follow/types/follow.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ export interface FollowListResponse {
2020
}
2121

2222
export type FollowSortType = 'LATEST' | 'OLDEST'
23+
24+
export interface FollowParams {
25+
cursor?: number
26+
limit?: number
27+
sort?: FollowSortType
28+
}

0 commit comments

Comments
 (0)