-
시청한 영화 담기
-
볼 영화 담기
+
+
+
))}
-
-
-
);
};
From 35db5383a2d6d4561bf8405c01e56ab58163bd3f Mon Sep 17 00:00:00 2001
From: Slity <0911kjw@naver.com>
Date: Wed, 14 May 2025 02:22:49 +0900
Subject: [PATCH 4/6] =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EA=B8=B0=EB=8A=A5=20?=
=?UTF-8?q?=EA=B5=AC=ED=98=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/fetchMovies.jsx | 64 ++++++++++++++++++++++++++++++++++++---------
1 file changed, 52 insertions(+), 12 deletions(-)
diff --git a/src/fetchMovies.jsx b/src/fetchMovies.jsx
index f0cf3c8..1569883 100644
--- a/src/fetchMovies.jsx
+++ b/src/fetchMovies.jsx
@@ -22,6 +22,8 @@ const fetchMovies = () => {
const FetchMovies = () => {
const [movies, setMovies] = useState([]);
const [loading, setLoading] = useState(true);
+ const [watched, setWatched] = useState([]);
+ const [toWatch, setToWatch] = useState([]);
useEffect(() => {
const loadMovies = async () => {
@@ -34,6 +36,26 @@ const FetchMovies = () => {
loadMovies();
}, []);
+ const addWatched = (movie) => {
+ setWatched((prev) => [...prev, movie]);
+ setMovies((prev) => prev.filter((m) => m.id !== movie.id));
+ };
+
+ const addToWatchList = (movie) => {
+ setToWatch((prev) => [...prev, movie]);
+ setMovies((prev) => prev.filter((m) => m.id !== movie.id));
+ };
+
+ const removeWatchedList = (movie) => {
+ setWatched((prev) => prev.filter((m) => m.id !== movie.id));
+ setMovies((prev) => [...prev, movie].sort((a, b) => a.id - b.id));
+ };
+
+ const removeToWatchList = (movie) => {
+ setToWatch((prev) => prev.filter((m) => m.id !== movie.id));
+ setMovies((prev) => [...prev, movie].sort((a, b) => a.id - b.id));
+ };
+
if (loading) {
return (
@@ -57,24 +79,35 @@ const FetchMovies = () => {
-
+
시청한 영화 목록
-
+ {watched.map((movie) => (
+
+
{movie.title}
+
+
+ ))}
-
From 97ccf37624df9ca4aabb38c3f37666bd5fd0bc8e Mon Sep 17 00:00:00 2001
From: Slity <0911kjw@naver.com>
Date: Wed, 14 May 2025 02:50:44 +0900
Subject: [PATCH 5/6] =?UTF-8?q?=EC=98=A4=EB=A6=84=EC=B0=A8=EC=88=9C=20?=
=?UTF-8?q?=EC=A0=95=EB=A0=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/fetchMovies.jsx | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/fetchMovies.jsx b/src/fetchMovies.jsx
index 1569883..c7bb9fd 100644
--- a/src/fetchMovies.jsx
+++ b/src/fetchMovies.jsx
@@ -36,24 +36,26 @@ const FetchMovies = () => {
loadMovies();
}, []);
+ const sortById = (list) => list.sort((a, b) => a.id - b.id);
+
const addWatched = (movie) => {
- setWatched((prev) => [...prev, movie]);
- setMovies((prev) => prev.filter((m) => m.id !== movie.id));
+ setWatched((prev) => sortById([...prev, movie]));
+ setMovies((prev) => sortById(prev.filter((m) => m.id !== movie.id)));
};
const addToWatchList = (movie) => {
- setToWatch((prev) => [...prev, movie]);
- setMovies((prev) => prev.filter((m) => m.id !== movie.id));
+ setToWatch((prev) => sortById([...prev, movie]));
+ setMovies((prev) => sortById(prev.filter((m) => m.id !== movie.id)));
};
const removeWatchedList = (movie) => {
- setWatched((prev) => prev.filter((m) => m.id !== movie.id));
- setMovies((prev) => [...prev, movie].sort((a, b) => a.id - b.id));
+ setWatched((prev) => sortById(prev.filter((m) => m.id !== movie.id)));
+ setMovies((prev) => sortById([...prev, movie]));
};
const removeToWatchList = (movie) => {
- setToWatch((prev) => prev.filter((m) => m.id !== movie.id));
- setMovies((prev) => [...prev, movie].sort((a, b) => a.id - b.id));
+ setToWatch((prev) => sortById(prev.filter((m) => m.id !== movie.id)));
+ setMovies((prev) => sortById([...prev, movie]));
};
if (loading) {
@@ -142,4 +144,4 @@ const FetchMovies = () => {
);
};
-export default FetchMovies;
+export default FetchMovies;
\ No newline at end of file
From 3813590f8fb16420eea8c4b9bb43d7c0af3827f9 Mon Sep 17 00:00:00 2001
From: Slity <0911kjw@naver.com>
Date: Wed, 14 May 2025 03:15:44 +0900
Subject: [PATCH 6/6] Update fetchMovies.jsx
---
src/fetchMovies.jsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/fetchMovies.jsx b/src/fetchMovies.jsx
index c7bb9fd..bf5f23a 100644
--- a/src/fetchMovies.jsx
+++ b/src/fetchMovies.jsx
@@ -38,7 +38,7 @@ const FetchMovies = () => {
const sortById = (list) => list.sort((a, b) => a.id - b.id);
- const addWatched = (movie) => {
+ const addWatchedList = (movie) => {
setWatched((prev) => sortById([...prev, movie]));
setMovies((prev) => sortById(prev.filter((m) => m.id !== movie.id)));
};
@@ -103,7 +103,7 @@ const FetchMovies = () => {
{movie.description}