[6주차] Team STORIX 김윤성&이채연 과제 제출합니다.#12
[6주차] Team STORIX 김윤성&이채연 과제 제출합니다.#12Tutankhannun wants to merge 37 commits intoCEOS-Developers:mainfrom
Conversation
Add GitHub collaboration branch strategy and workflow
fix: 경로 설정, svgr 설정
There was a problem hiding this comment.
과제하시느라 고생 많으셨습니다!!
제가 포크하신 레포지토리도 방문했는데, Issue나 PR 템플릿을 활용하셔서 작업하시면 더 좋을거 같습니다. 이슈, PR 템플릿
그리고 API 함수 작성하고 사용하는 부분에 대해서 찾아보시면 좋겠습니다.
다음 과제도 Next js를 사용하고, 백엔드와 api 연동이 있는걸로 예상되는데,
이전 기수들 PR 보시면서 api관련 코드들을 잘 읽어보시고 잘 협업하실 수 있으면 좋겠습니다!!
There was a problem hiding this comment.
피그마 디자인이 의도된게, search 페이지의 검색어가 없는 초기에는 Top Search가 뜨는게 맞지만,
검색 내용은 검색 api 해당 api를 사용하는게 맞습니다..!
해당 api 사용하는 걸로 변경하시고, debounce 처리도 하시면 좋을거 같습니다
| ''; | ||
| const url = `https://api.themoviedb.org/3/${media}/${id}?language=eng-US`; | ||
|
|
||
| const res = await fetch(url, { |
There was a problem hiding this comment.
보통 baseURL이나 엑세스 토큰을 HTTP 헤더에 넣은 기본 함수를 따로 생성하고,
그 기본 함수를 import해와서 API 경로나 쿼리 파라미터 등을 덧붙혀서 다른 API 함수를 생성하는 방식으로 API 관련 파일들을 구성합니다.
API 호출 관련 함수는 src/lib/api 폴더 아래에 정리해두시는게 좋을 거 같습니다.
There was a problem hiding this comment.
API 모듈 분리
API를 효율적으로 관리하는 방법
위 사이트의 폴더 구조가 정답은 아니지만 참고하시는 용도로 올려두겠습니다!
There was a problem hiding this comment.
확인해보니 tmdb.ts에 tmdbFetch라는 함수로 기본함수를 만들어 놓으셨는데,
tmdb.ts 파일 안에 정의를 하시거나 tmdbFetch함수를 이용하시면 좋을거 같습니다
| @@ -0,0 +1,50 @@ | |||
| // app/(frame)/detail/[media]/[id]/page.tsx | |||
| import Detail from '@components/detail/detail'; | |||
There was a problem hiding this comment.
절대경로 이렇게 하면 오류 발생 하나요..?? @/components/detail/Detail 이런식으로 수정해야할 거 같습니다
| if (!res.ok) { | ||
| throw new Error(`TMDB detail ${media}/${id} ${res.status}`); | ||
| } | ||
| return res.json(); |
There was a problem hiding this comment.
axios 라이브러리 적용하면 코드가 더 간단해질 수 있을 거 같아요
| export default function SplashLayout({ | ||
| children, | ||
| }: { | ||
| children: React.ReactNode; |
There was a problem hiding this comment.
import 방식으로 import type { ReactNode } from 'react'; 이게 더 좋을 거 같습니다
There was a problem hiding this comment.
왜 파일명이 hero인가요..? 좀 더 직관적인 방식으로 파일명을 정하는게 좋을 거 같아요..!! 그리고 컴포넌트 이름들이 다 소문자인데.. 대문자로 해서 구분하는 게 좋을 거 같아요
| : '/placeholder.png'; | ||
|
|
||
| return ( | ||
| <Link href="#"> |
There was a problem hiding this comment.
서치 페이지에서 영화 목록 누르면 상세페이지로 이동하지 않는데 의도하신건가요..??
sungahChooo
left a comment
There was a problem hiding this comment.
코드 잘 봤습니다. 과제 하느라 수고 많으셨어요!!! 👍🏻
jungyungee
left a comment
There was a problem hiding this comment.
과제하느라 수고 많으셨습니다..!!
잘 보았습니다. 코드와 결과물 보면서 몇 가지 개선할 점들 코멘트 달아보았습니다..!
| async function fetchTmdbDetail(media: 'movie' | 'tv', id: string) { | ||
| const token = | ||
| process.env.TMDB_ACCESS_TOKEN || | ||
| process.env.NEXT_PUBLIC_TMDB_ACCESS_TOKEN || | ||
| ''; | ||
| const url = `https://api.themoviedb.org/3/${media}/${id}?language=eng-US`; | ||
|
|
||
| const res = await fetch(url, { | ||
| headers: { | ||
| Authorization: `Bearer ${token}`, | ||
| 'Content-Type': 'application/json;charset=utf-8', | ||
| }, | ||
| cache: 'no-store', | ||
| }); | ||
| if (!res.ok) { | ||
| throw new Error(`TMDB detail ${media}/${id} ${res.status}`); | ||
| } | ||
| return res.json(); | ||
| } |
There was a problem hiding this comment.
주완 님이 리뷰남겨주신 것처럼 해당 API 호출은 api 폴더 내에서 함수로 정의해주시면 더 좋을 것 같습니다!
There was a problem hiding this comment.
전체적으로 components 내 파일명 규칙을 통일해주면 좋을 것 같습니다.!
| : '/placeholder.png'; | ||
|
|
||
| return ( | ||
| <Link href="#"> |
There was a problem hiding this comment.
하단바는 home이 아닌 navigation 등 다른 폴더로 빼는 게 더 좋을 것 같습니다.!
| const [activeMenu, setActiveMenu] = useState<string>(''); | ||
| const router = useRouter(); | ||
|
|
| activeMenu === key ? 'text-white' : 'text-menu-gray' | ||
| } hover:text-white ${clickable ? 'cursor-pointer' : 'cursor-default'}`} | ||
| > |


구현화면
배포링크
폴더구조
next-netflix-22nd
├─ app
│ ├─ (frame) # 공통 프레임용 그룹 라우트
│ │ ├─ detail
│ │ │ └─ [media]
│ │ │ └─ [id]
│ │ │ └─ page.tsx
│ │ ├─ home
│ │ │ ├─ layout.tsx
│ │ │ └─ page.tsx
│ │ └─ search
│ │ └─ page.tsx
│ │
│ ├─ (splash) #초기 스플레시 이미지
│ │ ├─ layout.tsx
│ │ └─ page.tsx
│ │
│ ├─ api
│ │ └─ tmdb
│ │ └─ top-rated
│ │ └─ route.ts # /api/tmdb/top-rated
│ │
│ ├─ fonts.css
│ ├─ globals.css
│ └─ layout.tsx # 앱 루트 레이아웃
│
├─ src
│ ├─ components
│ │ ├─ detail
│ │ │ └─ detail.tsx
│ │ ├─ home
│ │ │ ├─ cardrow.tsx
│ │ │ ├─ header.tsx
│ │ │ ├─ hero.tsx
│ │ │ ├─ herooverlay.tsx
│ │ │ ├─ menu.tsx
│ │ │ ├─ previews.tsx
│ │ │ └─ section.tsx
│ │ ├─ landing
│ │ │ └─ BrandSplash.tsx
│ │ ├─ layout
│ │ │ ├─ Footer.tsx
│ │ │ ├─ Header.tsx
│ │ │ └─ MobileTabBar.tsx
│ │ ├─ scroll
│ │ │ └─ scroll.tsx
│ │ └─ search
│ │ ├─ searchbox.tsx
│ │ ├─ searchitem.tsx
│ │ └─ searchresults.tsx
│ │
│ ├─ lib
│ │ └─ tmdb.ts # TMDB fetch/유틸
│ └─ types
│
├─ public
6주차 회고
👨🚀 김윤성
-5주차 때 피드백으로 받은 폴더구조를 참고해 리팩토링을 한 후 6주차 과제를 진행했다.
이번 주차 때는 api의 어느 데이터를 얼마나 가져오고 언제 요청하는 지 등 다양하게 다뤄보며 공부해 볼 수 있었다.
👩🚀 이채연