Skip to content

Commit

Permalink
Merge pull request #55 from RyuDongHo/main
Browse files Browse the repository at this point in the history
[4주차/다일] 워크북 제출합니다
  • Loading branch information
RyuDongHo authored Nov 4, 2024
2 parents 1fc6de2 + fe2736f commit 581ac3b
Show file tree
Hide file tree
Showing 46 changed files with 5,889 additions and 4 deletions.
344 changes: 344 additions & 0 deletions keyword/chapter04/keyword.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from "react";
import apiConfig from "../../../../../Shared/config/apiConfig";
const BASE_URL = import.meta.env.VITE_TMDB_BASE_URL;
const BASE_IMG_URL = "https://image.tmdb.org/t/p/";
const BASE_IMG_SIZE = "w500";

const useMovieList = (category, page) => {
const [movieList, setMovieList] = React.useState([]);

React.useEffect(() => {
const fetchMovie = async () => {
const response = await fetch(
`${BASE_URL}/account/${1}`,
apiConfig("GET"),
);

let result = [];
const status = response.status;
switch (status) {
case 200:
result = await response.json();
break;
default:
alert("api error");
result = null;
break;
}

result.forEach(e => {
e.poster_path = `${BASE_IMG_URL}${BASE_IMG_SIZE}${e.poster_path}`;
});

setMovieList(result);
};

fetchMovie();
}, [category, page]);

return [movieList.results];
};
export default useMovieList;
8 changes: 8 additions & 0 deletions mission/chapter03/mission/src/Page/MovieDetailPage/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";

const MovieDetailPage = () => {


};

export default MovieDetailPage;
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from "react";
import apiConfig from "../../../../../Shared/config/apiConfig";
const BASE_URL = import.meta.env.VITE_TMDB_BASE_URL;
const BASE_IMG_URL = "https://image.tmdb.org/t/p/";
const BASE_IMG_SIZE = "w500";

const useMovieList = (category, page) => {
const [movieList, setMovieList] = React.useState([]);

React.useEffect(() => {
const fetchMovie = async () => {
const response = await fetch(
Expand All @@ -23,6 +24,11 @@ const useMovieList = (category, page) => {
result = null;
break;
}

result.forEach(e => {
e.poster_path = `${BASE_IMG_URL}${BASE_IMG_SIZE}${e.poster_path}`;
});

setMovieList(result);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import useMovieList from "./api/useMovieList";
import STYLE from "./style";
import React from "react";
const BASE_IMG_URL = "https://image.tmdb.org/t/p/";
const BASE_IMG_SIZE = "w500";

const MovieList = (props) => {
const [page, setPage] = React.useState(1);
// page 전환 기능을 넣게 된다면 state로 관리합니다.
Expand All @@ -15,7 +14,7 @@ const MovieList = (props) => {
return (
<STYLE.Movie className="movie" key={index}>
<STYLE.Thumbnail
src={`${BASE_IMG_URL}${BASE_IMG_SIZE}${elem.poster_path}`}
src={`${elem.poster_path}`}
alt="movie poster"
/>
<STYLE.ThumbnailHoverEffectDiv />
Expand Down
25 changes: 25 additions & 0 deletions mission/chapter04/mission/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.env
8 changes: 8 additions & 0 deletions mission/chapter04/mission/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# React + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
39 changes: 39 additions & 0 deletions mission/chapter04/mission/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import js from '@eslint/js'
import globals from 'globals'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'

export default [
{ ignores: ['dist'] },
{
files: ['**/*.{js,jsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
settings: { react: { version: '18.3' } },
plugins: {
react,
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...js.configs.recommended.rules,
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
...reactHooks.configs.recommended.rules,
'react/jsx-no-target-blank': 'off',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
"react/prop-types": "off"
},
},
]
13 changes: 13 additions & 0 deletions mission/chapter04/mission/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
</head>
<body>
<div class="body" id="root"></div>
<script type="module" src="/src/index.jsx"></script>
</body>
</html>
Loading

0 comments on commit 581ac3b

Please sign in to comment.