-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
367 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,5 @@ dist-ssr | |
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions
24
mission/chapter03/mission_ch03/src/components/CategoryList.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { MoviesGrid, MovieCard, MovieImage, MovieLabel } from "../styled/Movie.styled"; | ||
|
||
const CategoryList = ({ categories }) => { | ||
return ( | ||
<MoviesGrid> | ||
{categories.map((category) => ( | ||
<Link | ||
key={category.id} | ||
to={category.endpoint} // Link의 to 속성에 엔드포인트 전달 | ||
style={{ textDecoration: 'none', color: 'inherit' }} // 기본 스타일 제거 | ||
> | ||
<MovieCard> | ||
<MovieImage src={category.imgSrc} alt={category.title} /> | ||
<MovieLabel>{category.title}</MovieLabel> | ||
</MovieCard> | ||
</Link> | ||
))} | ||
</MoviesGrid> | ||
); | ||
}; | ||
|
||
export default CategoryList; |
29 changes: 29 additions & 0 deletions
29
mission/chapter03/mission_ch03/src/components/MovieDetail.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// MovieDetail.js | ||
import React from "react"; | ||
import { useParams } from "react-router-dom"; | ||
import useCustomFetch from "../hooks/useCustomFetch"; | ||
import { MovieDetailContainer, MovieTitle, MovieOverview, MoviePoster } from "../styled/MovieDetail.styled"; | ||
|
||
const MovieDetail = () => { | ||
const { movieId } = useParams(); // URL에서 movieId를 가져옴 | ||
const apiKey = import.meta.env.VITE_TMDB_API_KEY; | ||
const { data: movies, isLoading, isError } = useCustomFetch(`https://api.themoviedb.org/3/movie/${movieId}?api_key=${apiKey}&language=ko-KR`); | ||
if (isLoading) return <div>Loading...</div>; | ||
if (isError) return <div>Error loading movie details.</div>; | ||
|
||
// movie가 undefined가 아닌 경우에만 렌더링 | ||
return ( | ||
<MovieDetailContainer> | ||
{movies.results?.map((movie) => ( | ||
<div key={movie.id}> | ||
<MoviePoster src={`https://image.tmdb.org/t/p/w300${movie.poster_path}`} alt={movie.title} /> | ||
<MovieTitle>{movie.title}</MovieTitle> | ||
<MovieOverview>{movie.overview}</MovieOverview> | ||
</div> | ||
))} | ||
</MovieDetailContainer> | ||
|
||
); | ||
}; | ||
|
||
export default MovieDetail; |
57 changes: 0 additions & 57 deletions
57
mission/chapter03/mission_ch03/src/components/MovieItem.jsx
This file was deleted.
Oops, something went wrong.
28 changes: 20 additions & 8 deletions
28
mission/chapter03/mission_ch03/src/components/MovieList.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
//import React from 'react'; | ||
import MovieItem from './MovieItem'; | ||
import { MovieListContainer } from './MovieList.styled'; | ||
import React from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { MoviesGrid, MovieCard, MovieImage, MovieTitle } from "../styled/Movie.styled"; | ||
|
||
function MovieList({ movies }) { | ||
const MovieList = ({ movies }) => { | ||
return ( | ||
<MovieListContainer> | ||
<MoviesGrid> | ||
{movies.map((movie) => ( | ||
<MovieItem key={movie.id} movie={movie} /> | ||
<Link | ||
key={movie.id} | ||
to={`/movies/${movie.id}`} // 각 영화의 ID를 포함한 경로로 링크 설정 | ||
style={{ textDecoration: 'none', color: 'inherit' }} | ||
> | ||
<MovieCard> | ||
<MovieImage | ||
src={`https://image.tmdb.org/t/p/w200${movie.poster_path}`} | ||
alt={movie.title} | ||
/> | ||
<MovieTitle>{movie.title}</MovieTitle> | ||
</MovieCard> | ||
</Link> | ||
))} | ||
</MovieListContainer> | ||
</MoviesGrid> | ||
); | ||
} | ||
}; | ||
|
||
export default MovieList; |
9 changes: 0 additions & 9 deletions
9
mission/chapter03/mission_ch03/src/components/custom-button.jsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
mission/chapter03/mission_ch03/src/hooks/useCustomFetch.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useEffect, useState } from "react"; | ||
import axios from "axios"; | ||
|
||
const useCustomFetch = (url) =>{ | ||
const [data, setData] = useState([]); | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [isError, setIsError] = useState(false); | ||
useEffect(()=>{ | ||
const fetchData = async()=>{ | ||
setIsLoading(true); | ||
try{ | ||
const response = await axios.get(url); | ||
setData(response.data); | ||
} | ||
catch (error){ | ||
setIsError(error); | ||
} | ||
finally{ | ||
setIsLoading(false); | ||
} | ||
} | ||
fetchData(); | ||
},[url]); | ||
|
||
return {data,isLoading,isError}; | ||
} | ||
|
||
export default useCustomFetch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body{ | ||
margin : 0; | ||
} |
Oops, something went wrong.