-
Notifications
You must be signed in to change notification settings - Fork 0
[feat/interview-chart] - 인터뷰 목록 + 차트 컴포넌트 #13
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 1 commit
b9e4402
b763fa5
6cd4176
dc98d9b
ffbaf3c
35080c6
8608344
eae1cf2
40f38e3
52f92d0
d8d9acf
84a84db
825afdd
6d6543d
34dfc16
aeab522
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,7 +15,7 @@ export default async function HomePage() { | |||||
| <HeaderMain /> | ||||||
| <div className="w-[1043px] mx-auto"> | ||||||
| <div className="flex flex-col items-center justify-start h-full"> | ||||||
| <main className="flex mt-[168px] gap-4 h-[617px]"> | ||||||
| <main className="flex mt-[186px] gap-4 h-[617px]"> | ||||||
|
||||||
| <main className="flex mt-[186px] gap-4 h-[617px]"> | |
| <main className="flex mt-custom-186 gap-4 h-[617px]"> |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,48 @@ | ||||||||||||||
| export default function ChartComponent(tracksList: any) { | ||||||||||||||
| import Image from "next/image"; | ||||||||||||||
| import { TrackItem } from "@/shared/types/SpotifyTrack"; | ||||||||||||||
|
|
||||||||||||||
| interface ChartComponentProps { | ||||||||||||||
| tracksList: TrackItem[]; | ||||||||||||||
| title: string; | ||||||||||||||
| className?: string; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| export default function ChartComponent({ | ||||||||||||||
| tracksList, | ||||||||||||||
| title, | ||||||||||||||
| className = "", | ||||||||||||||
| }: ChartComponentProps) { | ||||||||||||||
| return ( | ||||||||||||||
| <div> | ||||||||||||||
| <div className="text-lg">차트 컴포넌트</div> | ||||||||||||||
| <div | ||||||||||||||
| className={`relative border-3 border-black p-5 mt-10 max-w-7xl bg-white w-full ${className}`} | ||||||||||||||
|
||||||||||||||
| className={`relative border-3 border-black p-5 mt-10 max-w-7xl bg-white w-full ${className}`} | |
| className={`relative border-2 border-black p-5 mt-10 max-w-7xl bg-white w-full ${className}`} |
Copilot
AI
Jul 1, 2025
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.
Using the array index as a React key can lead to rendering issues; prefer a stable, unique identifier if available.
| {tracksList.map((item, index) => ( | |
| <div | |
| key={index} | |
| {tracksList.map((item) => ( | |
| <div | |
| key={item.track.id} |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,8 @@ | ||||||
| import Image from "next/image"; | ||||||
|
|
||||||
| import Miniplayer from "@/features/chart/components/Miniplayer"; | ||||||
| import InterviewList from "@/features/homepage/components/InterviewList"; | ||||||
|
|
||||||
| import { getYoutubeTrackIdVideo } from "@/features/tracks/hooks/getYoutube"; | ||||||
| import { TrackItem } from "@/shared/types/SpotifyTrack"; | ||||||
|
|
||||||
|
|
@@ -20,22 +22,26 @@ export default async function ChartTop({ | |||||
| return <div>트랙이 없습니다.</div>; | ||||||
| } | ||||||
| return ( | ||||||
| <div className="relative border-2 border-black p-10 mt-10 max-w-7xl mx-auto bg-white"> | ||||||
| <div className="relative border-3 border-black p-10 mt-10 max-w-7xl mx-auto bg-white"> | ||||||
|
||||||
| <div className="relative border-3 border-black p-10 mt-10 max-w-7xl mx-auto bg-white"> | |
| <div className="relative border-2 border-black p-10 mt-10 max-w-7xl mx-auto bg-white"> |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -5,45 +5,51 @@ import { connectToDB } from "@/lib/mongo"; | |||
| export async function getYoutubeTrackIdVideo( | ||||
| trackName: string | ||||
| ): Promise<YoutubeVideo[]> { | ||||
| const db = await connectToDB(); | ||||
| const collection = db.collection("musicVideos"); | ||||
|
|
||||
| const cached = await collection.findOne({ trackName }); | ||||
|
|
||||
| if (cached) { | ||||
| return cached.videos; | ||||
| } | ||||
|
|
||||
| const baseUrl = process.env.BASE_URL || "http://127.0.0.1:3000"; | ||||
|
|
||||
| const res = await fetch( | ||||
| `${baseUrl}/api/youtube-search?q=${encodeURIComponent(trackName)}` | ||||
| ); | ||||
|
|
||||
| if (!res.ok) { | ||||
| throw new Error("유튜브 검색에 실패했습니다"); | ||||
| } | ||||
|
|
||||
| const data = await res.json(); | ||||
| const videos = data.items || []; | ||||
|
|
||||
| if (videos.length === 0) { | ||||
| throw new Error("비디오를 찾을 수 없습니다"); | ||||
| } | ||||
|
|
||||
| await collection.updateOne( | ||||
| { trackName }, | ||||
| { | ||||
| $set: { | ||||
| trackName, | ||||
| videos, | ||||
| updatedAt: Date.now(), | ||||
| try { | ||||
| const db = await connectToDB(); | ||||
| const collection = db.collection("musicVideos"); | ||||
|
|
||||
| const cached = await collection.findOne({ trackName }); | ||||
|
|
||||
| if (cached) { | ||||
| return cached.videos; | ||||
| } | ||||
|
|
||||
| const baseUrl = process.env.BASE_URL || "http://127.0.0.1:3000"; | ||||
|
|
||||
| const res = await fetch( | ||||
| `${baseUrl}/api/youtube-search?q=${encodeURIComponent(trackName)}` | ||||
| ); | ||||
|
|
||||
| if (!res.ok) { | ||||
| throw new Error("유튜브 검색에 실패했습니다"); | ||||
| return []; | ||||
|
||||
| return []; |
Copilot
AI
Jul 1, 2025
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.
Similarly, this return [] after a throw is unreachable and should be removed for clarity.
| return []; |
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.
Remove or guard this
console.logto avoid leaking debug output in production.