-
Notifications
You must be signed in to change notification settings - Fork 2
[feat] /mycd playlistId 기반 라우팅 처리 #117
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
Changes from all commits
86dd66a
a15e506
6ea4334
dde19dd
98a6aaf
33e9efc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| import { useState, useCallback, type Key } from 'react' | ||
| import { useState, useCallback, useEffect, type Key } from 'react' | ||
| import { useParams } from 'react-router-dom' | ||
|
|
||
| import styled from 'styled-components' | ||
|
|
||
| import type { CdCustomData } from '@/entities/playlist' | ||
| import type { CdCustomData, PlaylistInfo } from '@/entities/playlist' | ||
| import { SwipeCarousel } from '@/features/swipe' | ||
| import { flexRowCenter } from '@/shared/styles/mixins' | ||
| import { Cd } from '@/shared/ui' | ||
| import LoopCarousel from '@/shared/ui/LoopCarousel' | ||
|
|
||
| interface CarouselPlaylist { | ||
| playlistId: number | ||
|
|
@@ -19,8 +20,18 @@ interface PlaylistCarouselProps { | |
| } | ||
|
|
||
| const PlaylistCarousel = ({ data, onCenterChange }: PlaylistCarouselProps) => { | ||
| const { id: playlistId } = useParams() | ||
| const [activeIndex, setActiveIndex] = useState(0) | ||
|
|
||
| // url 기준으로 active index 동기화 | ||
| useEffect(() => { | ||
| if (!playlistId) return | ||
|
|
||
| const index = data.findIndex((p) => p.playlistId === Number(playlistId)) | ||
|
|
||
| if (index >= 0) setActiveIndex(index) | ||
| }, [playlistId, data]) | ||
|
|
||
| const handleSelectIndex = useCallback( | ||
| (index: number) => { | ||
| setActiveIndex(index) | ||
|
|
@@ -35,20 +46,34 @@ const PlaylistCarousel = ({ data, onCenterChange }: PlaylistCarouselProps) => { | |
| [data, onCenterChange] | ||
| ) | ||
|
|
||
| const playlistInfoData: PlaylistInfo[] = data.map((p) => ({ | ||
| playlistId: p.playlistId, | ||
| playlistName: p.playlistName, | ||
| creator: { creatorId: '0', creatorNickname: '' }, | ||
| genre: '', | ||
| songs: [], | ||
| isPublic: true, | ||
| })) | ||
|
Comment on lines
+49
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Style Guide ReferencesFootnotes
|
||
|
|
||
| return ( | ||
| <LoopCarousel onSelectIndex={handleSelectIndex}> | ||
| <SwipeCarousel | ||
| data={playlistInfoData} | ||
| onSelectIndexChange={handleSelectIndex} | ||
| axis="x" | ||
| basePath="/mycd" | ||
| > | ||
| {data.map((slide, index: Key) => ( | ||
| <EmblaSlide key={index}> | ||
| <Slide $active={activeIndex === index}> | ||
| <Cd | ||
| variant="carousel" | ||
| variant="mycd" | ||
| bgColor="none" | ||
| stickers={activeIndex === index ? slide.cdResponse.cdItems : []} | ||
| /> | ||
| </Slide> | ||
| </EmblaSlide> | ||
| ))} | ||
| </LoopCarousel> | ||
| </SwipeCarousel> | ||
| ) | ||
| } | ||
|
|
||
|
|
||
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.
오타 수정 필요.
VerticaContainer는 오타입니다.VerticalContainer로 수정해야 합니다.다음 diff를 적용하세요:
그리고 69번 라인의 사용처도 함께 수정:
🤖 Prompt for AI Agents