@@ -4,7 +4,9 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom'
44import styled from 'styled-components'
55
66import { usePlaylist } from '@/app/providers/PlayerProvider'
7+ import { NoLike } from '@/assets/icons'
78import { MemberCharacter } from '@/assets/images'
9+ import { usePlaylistDetail } from '@/entities/playlist'
810import { useMyCdActions , useMyCdList , useMyLikedCdList } from '@/entities/playlist/model/useMyCd'
911import { useAuthStore } from '@/features/auth/store/authStore'
1012import { useChatSocket } from '@/features/chat/model/sendMessage'
@@ -13,7 +15,7 @@ import type { MyCdTab } from '@/pages/mycd/ui/HeaderTab'
1315import { getVideoId } from '@/shared/lib'
1416import { useDevice } from '@/shared/lib/useDevice'
1517import { flexColCenter , flexRowCenter } from '@/shared/styles/mixins'
16- import { Button , LiveInfo } from '@/shared/ui'
18+ import { Button , LiveInfo , Loading } from '@/shared/ui'
1719import { ActionBar , ControlBar , ProgressBar , VolumeButton , YoutubePlayer } from '@/widgets/playlist'
1820
1921const MyCdPage = ( ) => {
@@ -45,10 +47,11 @@ const MyCdPage = () => {
4547 const likedCdPlaylist = useMyLikedCdList ( 'RECENT' )
4648
4749 const playlistQuery = selectedTab === 'MY' ? myCdPlaylist : likedCdPlaylist
48-
4950 const playlistData = useMemo ( ( ) => playlistQuery . data ?? [ ] , [ playlistQuery . data ] )
50-
51+ const isLoading = playlistQuery . isLoading
5152 const isError = playlistQuery . isError
53+ const isMyEmpty = ! myCdPlaylist . isLoading && ( myCdPlaylist . data ?. length ?? 0 ) === 0
54+ const isLikedEmpty = ! likedCdPlaylist . isLoading && ( likedCdPlaylist . data ?. length ?? 0 ) === 0
5255
5356 const [ centerItem , setCenterItem ] = useState < {
5457 playlistId : number | null
@@ -112,9 +115,15 @@ const MyCdPage = () => {
112115 )
113116
114117 /* 플레이리스트 세팅 */
115- const { tracklist : playlistDetail } = useMyCdActions ( Number ( centerItem . playlistId ) , {
116- enabled : ! ! centerItem . playlistId ,
118+ const myCdDetail = useMyCdActions ( Number ( centerItem . playlistId ) , {
119+ enabled : selectedTab === 'MY' && ! ! centerItem . playlistId ,
120+ } )
121+
122+ const likedCdDetail = usePlaylistDetail ( centerItem . playlistId , {
123+ enabled : selectedTab === 'LIKE' && ! ! centerItem . playlistId ,
117124 } )
125+
126+ const playlistDetail = selectedTab === 'MY' ? myCdDetail . tracklist : likedCdDetail . data
118127 useEffect ( ( ) => {
119128 if ( playlistDetail && userInfo ) {
120129 if ( currentPlaylist ?. playlistId === playlistDetail . playlistId ) return
@@ -162,21 +171,41 @@ const MyCdPage = () => {
162171 ? getVideoId ( currentPlaylist . songs [ currentTrackIndex ] ?. youtubeUrl )
163172 : null
164173
174+ if ( isLoading ) {
175+ return < Loading isLoading />
176+ }
177+
165178 if ( isError ) {
166179 navigate ( '/error' )
167180 return null
168181 }
169182
170- const isEmpty = playlistData && playlistData . length === 0
183+ if ( selectedTab === 'MY' && isMyEmpty ) {
184+ return (
185+ < EmptyPage >
186+ < HeaderTab selectedTab = { selectedTab } onSelect = { handleTabSelect } />
187+ < CenterContent >
188+ < img src = { MemberCharacter } alt = "Guest Character" width = { 160 } height = { 160 } />
189+ < NavigateBtn onClick = { ( ) => navigate ( '/mypage/customize' ) } >
190+ 새로운 CD에 취향 담기
191+ </ NavigateBtn >
192+ </ CenterContent >
193+ </ EmptyPage >
194+ )
195+ }
171196
172- if ( isEmpty ) {
197+ if ( selectedTab === 'LIKE' && isLikedEmpty ) {
173198 return (
174- < ViewContainer >
175- < img src = { MemberCharacter } alt = "Guest Character" width = { 160 } height = { 160 } />
176- < NavigateBtn onClick = { ( ) => navigate ( '/mypage/customize' ) } >
177- 새로운 CD에 취향 담기
178- </ NavigateBtn >
179- </ ViewContainer >
199+ < EmptyPage >
200+ < HeaderTab selectedTab = { selectedTab } onSelect = { handleTabSelect } />
201+ < CenterContent >
202+ < NoLike width = { 160 } height = { 160 } />
203+ < SubText >
204+ 아직 좋아요한 CD가 없어요. < br /> 새로운 음악을 찾아볼까요?
205+ </ SubText >
206+ < NavigateBtn onClick = { ( ) => navigate ( '/discover' ) } > 둘러보기로 가기</ NavigateBtn >
207+ </ CenterContent >
208+ </ EmptyPage >
180209 )
181210 }
182211
@@ -204,18 +233,18 @@ const MyCdPage = () => {
204233 </ Button >
205234 ) }
206235 </ Container >
207-
208236 < PlaylistCarousel data = { playlistData ?? [ ] } onCenterChange = { handleCenterChange } />
209-
210237 < ActionBar
211238 playlistId = { centerItem . playlistId ?? 0 }
212239 creatorId = { currentPlaylist . creator . creatorId }
213240 stickers = { playlistDetail ?. cdResponse ?. cdItems || [ ] }
214241 type = "MY"
215242 selectedTab = { selectedTab }
216243 />
217-
218- < Title > { centerItem . playlistName } </ Title >
244+ < Title $isMobile = { isMobile } > { centerItem . playlistName } </ Title >
245+ { selectedTab === 'LIKE' && playlistDetail ?. creatorNickname && (
246+ < Creator > { playlistDetail . creatorNickname } </ Creator >
247+ ) }
219248
220249 < BottomWrapper >
221250 < ProgressBar
@@ -259,24 +288,18 @@ const Container = styled.div`
259288 height: 30px;
260289`
261290
262- const Title = styled . p `
291+ const Title = styled . p < { $isMobile ?: boolean } > `
263292 ${ ( { theme } ) => theme . FONT . headline1 } ;
264- padding-top: 40px;
293+ padding-top: ${ ( { $isMobile } ) => ( $isMobile ? '24px' : ' 40px' ) } ;
265294`
266295
267296const BottomWrapper = styled . div `
268- padding-top: 24px ;
297+ padding-top: 20px ;
269298 display: flex;
270299 flex-direction: column;
271300 gap: 20px;
272301`
273302
274- const ViewContainer = styled . div `
275- ${ flexColCenter }
276- height: 100%;
277- gap: 16px;
278- `
279-
280303const NavigateBtn = styled . button `
281304 ${ flexRowCenter }
282305 background-color: ${ ( { theme } ) => theme . COLOR [ 'primary-normal' ] } ;
@@ -285,4 +308,27 @@ const NavigateBtn = styled.button`
285308 padding: 6px 20px;
286309 height: 32px;
287310 ${ ( { theme } ) => theme . FONT [ 'body2-normal' ] } ;
311+ margin-top: 16px;
312+ `
313+ const Creator = styled . p `
314+ ${ ( { theme } ) => theme . FONT [ 'body2-normal' ] } ;
315+ color: ${ ( { theme } ) => theme . COLOR [ 'gray-300' ] } ;
316+ `
317+
318+ const SubText = styled . p `
319+ ${ ( { theme } ) => theme . FONT [ 'body1-normal' ] }
320+ color: ${ ( { theme } ) => theme . COLOR [ 'gray-50' ] } ;
321+ `
322+
323+ const EmptyPage = styled . div `
324+ display: flex;
325+ flex-direction: column;
326+ height: 100%;
327+ background-color: ${ ( { theme } ) => theme . COLOR [ 'gray-900' ] } ;
328+ `
329+
330+ const CenterContent = styled . div `
331+ flex: 1;
332+ ${ flexColCenter } ;
333+ text-align: center;
288334`
0 commit comments