From 2a1e6640deb0078ba7b03655bd336b5ac0cac66d Mon Sep 17 00:00:00 2001 From: HyeonChae1104 <211063@jnu.ac.kr> Date: Sun, 9 Jun 2024 18:23:49 +0900 Subject: [PATCH 01/18] =?UTF-8?q?Docs:=20=EA=B5=AC=ED=98=84=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c0710d2..bc6ac07a 100644 --- a/README.md +++ b/README.md @@ -1 +1,16 @@ -# react-todo-list-precourse \ No newline at end of file +# react-todo-list-precourse + +하루 또는 한 주의 목록을 업데이트하는 할 일 목록을 구현한다. + +### 할 일 추가/삭제 +- 추가할 때 사용자는 Enter나 '추가'버튼을 사용하여 할 일을 목록에 추가할 수 있어야 한다. +- 사용자가 아무것도 입력하지 않은 경우, 할 일을 추가할 수 없다. +- 할 일의 목록을 볼 수 있다. +- 할 일의 완료 상태를 전환할 수 있다. + +### 선택 요구 사항 +- 현재 진행 중인 할 일, 완료된 할 일, 모든 할 일을 필터링할 수 있다. +- 해야할 일의 총 개수를 확인할 수 있다. +- 새로고침을 하여도 이전에 작성한 데이터는 유지되어야 한다. + +### UI는 자유롭게 만드는 것이 가능하다. \ No newline at end of file From 213b69c33b4467df5ff323510d4a4f51677c68a6 Mon Sep 17 00:00:00 2001 From: HyeonChae1104 <211063@jnu.ac.kr> Date: Mon, 10 Jun 2024 01:04:06 +0900 Subject: [PATCH 02/18] =?UTF-8?q?feat:=20=EA=B8=B0=EB=B3=B8=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EB=B0=8F=20=EC=B4=88=EA=B8=B0=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=20=EA=B4=80=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.jsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/App.jsx diff --git a/src/App.jsx b/src/App.jsx new file mode 100644 index 00000000..1a58d10c --- /dev/null +++ b/src/App.jsx @@ -0,0 +1,19 @@ +import React, { useState, useEffect } from 'react'; +import TodoList from '../components/TodoList'; +import './App.css'; + +function App() { + const [todos, setTodos] = useState([]); + const [filter, setFilter] = useState('all'); + + useEffect(() => { + const savedTodos = JSON.parse(localStorage.getItem('todos')); + if (savedTodos) { + setTodos(savedTodos); + } + }, []); + + useEffect(() => { + localStorage.setItem('todos', JSON.stringify(todos)); + }, [todos]); +} From ecc94829352ad30403b337d928d439f49ce4ed11 Mon Sep 17 00:00:00 2001 From: HyeonChae1104 <211063@jnu.ac.kr> Date: Mon, 10 Jun 2024 01:07:05 +0900 Subject: [PATCH 03/18] =?UTF-8?q?feat:=20=ED=95=A0=20=EC=9D=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/App.jsx b/src/App.jsx index 1a58d10c..968a24ff 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,5 +1,6 @@ import React, { useState, useEffect } from 'react'; import TodoList from '../components/TodoList'; +import AddTodo from '../components/AddTodo'; import './App.css'; function App() { @@ -16,4 +17,8 @@ function App() { useEffect(() => { localStorage.setItem('todos', JSON.stringify(todos)); }, [todos]); + + const addTodo = (text) => { + setTodos([...todos, { text, completed: false }]); + }; } From 2c56649b444d92e0726045222c473863acb0447f Mon Sep 17 00:00:00 2001 From: HyeonChae1104 <211063@jnu.ac.kr> Date: Mon, 10 Jun 2024 01:07:57 +0900 Subject: [PATCH 04/18] =?UTF-8?q?feat:=20=ED=95=A0=20=EC=9D=BC=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/App.jsx b/src/App.jsx index 968a24ff..286d9b9b 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -21,4 +21,11 @@ function App() { const addTodo = (text) => { setTodos([...todos, { text, completed: false }]); }; + + const deleteTodo = (index) => { + const newTodos = [...todos]; + newTodos.splice(index, 1); + setTodos(newTodos); + }; + } From cde2843d83ce0e73156972d1556eba377b81bf31 Mon Sep 17 00:00:00 2001 From: HyeonChae1104 <211063@jnu.ac.kr> Date: Mon, 10 Jun 2024 01:08:45 +0900 Subject: [PATCH 05/18] =?UTF-8?q?feat:=20=ED=95=A0=20=EC=9D=BC=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20=EC=83=81=ED=83=9C=20=ED=86=A0=EA=B8=80=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/App.jsx b/src/App.jsx index 286d9b9b..de7b3d0f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -28,4 +28,11 @@ function App() { setTodos(newTodos); }; + const toggleComplete = (index) => { + const newTodos = [...todos]; + newTodos[index].completed = !newTodos[index].completed; + setTodos(newTodos); + }; + + } From bd1ccac33f2d0a6ec475e890fee5f4289d88b8f6 Mon Sep 17 00:00:00 2001 From: HyeonChae1104 <211063@jnu.ac.kr> Date: Mon, 10 Jun 2024 01:10:15 +0900 Subject: [PATCH 06/18] =?UTF-8?q?feat:=20=ED=95=84=ED=84=B0=EB=A7=81=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/App.jsx b/src/App.jsx index de7b3d0f..ae98358f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; import TodoList from '../components/TodoList'; import AddTodo from '../components/AddTodo'; +import TodoFilter from '../components/TodoFilter'; import './App.css'; function App() { @@ -34,5 +35,10 @@ function App() { setTodos(newTodos); }; - + const filteredTodos = todos.filter(todo => { + if (filter === 'all') return true; + if (filter === 'active') return !todo.completed; + if (filter === 'completed') return todo.completed; + return true; + }); } From 3889e8b057241e965c03dcb89df921e397fa72a2 Mon Sep 17 00:00:00 2001 From: HyeonChae1104 <211063@jnu.ac.kr> Date: Mon, 10 Jun 2024 01:12:26 +0900 Subject: [PATCH 07/18] =?UTF-8?q?feat:=20=EC=BB=B4=ED=8F=AC=EB=84=8C?= =?UTF-8?q?=ED=8A=B8=20=EB=A0=8C=EB=8D=94=EB=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/App.jsx b/src/App.jsx index ae98358f..9c57fded 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -41,4 +41,15 @@ function App() { if (filter === 'completed') return todo.completed; return true; }); + +return ( +