From 269edddad3c991c2c5d479ba6439461328ceb95f Mon Sep 17 00:00:00 2001 From: SungwonShim Date: Thu, 22 Sep 2022 00:41:28 +0900 Subject: [PATCH] Finished in Session --- package.json | 2 + src/App.tsx | 20 +- src/components/Todo/Todo.tsx | 19 +- src/components/TodoDetail/TodoDetail.tsx | 25 +- src/containers/TodoList/NewTodo/NewTodo.tsx | 41 +- src/containers/TodoList/TodoList.tsx | 48 +- yarn.lock | 9079 +++++++++++++++++++ 7 files changed, 9227 insertions(+), 7 deletions(-) create mode 100644 yarn.lock diff --git a/package.json b/package.json index 0f38547..e4bca0c 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,8 @@ "@types/react-dom": "18.0.6", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-router": "^6.4.0", + "react-router-dom": "^6.4.0", "react-scripts": "5.0.1", "typescript": "4.7.4", "web-vitals": "2.1.4" diff --git a/src/App.tsx b/src/App.tsx index 9d18e93..fad8090 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,7 +1,21 @@ -import "./App.css"; +import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom"; +import TodoList from "./containers/TodoList/TodoList"; +import NewTodo from "./containers/TodoList/NewTodo/NewTodo"; +import TodoDetail from "./components/TodoDetail/TodoDetail"; function App() { - return
; + return ( +
+ + + } /> + } /> + } /> + } /> + Not Found} /> + + +
); } -export default App; +export default App; \ No newline at end of file diff --git a/src/components/Todo/Todo.tsx b/src/components/Todo/Todo.tsx index cb0ff5c..ec27880 100644 --- a/src/components/Todo/Todo.tsx +++ b/src/components/Todo/Todo.tsx @@ -1 +1,18 @@ -export {}; +import "./Todo.css" + +interface IProps { + title: string; + clicked?: React.MouseEventHandler; // Defined by React + done: boolean; +} +const Todo = (props: IProps) => { + return ( +
+
+ {props.title} +
+ {props.done &&
} +
+ ); +}; +export default Todo; \ No newline at end of file diff --git a/src/components/TodoDetail/TodoDetail.tsx b/src/components/TodoDetail/TodoDetail.tsx index cb0ff5c..979cc4a 100644 --- a/src/components/TodoDetail/TodoDetail.tsx +++ b/src/components/TodoDetail/TodoDetail.tsx @@ -1 +1,24 @@ -export {}; +import "./TodoDetail.css"; + +type Props = { + title: string; + content: string; +}; + +const TodoDetail = (props: Props) => { + return ( +
+
+
Name:
+
{props.title}
+
+
+
Content:
+
+ {props.content} +
+
+
+ ); +}; +export default TodoDetail; \ No newline at end of file diff --git a/src/containers/TodoList/NewTodo/NewTodo.tsx b/src/containers/TodoList/NewTodo/NewTodo.tsx index cb0ff5c..359ddcc 100644 --- a/src/containers/TodoList/NewTodo/NewTodo.tsx +++ b/src/containers/TodoList/NewTodo/NewTodo.tsx @@ -1 +1,40 @@ -export {}; +import { useState } from "react"; +import "./NewTodo.css"; +import { Navigate } from "react-router-dom"; + +export default function NewTodo() { + const [title, setTitle] = useState(""); + const [content, setContent] = useState(""); + const [submitted, setSubmitted] = useState(false); + const postTodoHandler = () => { + const data = { title: title, content: content }; + alert("Submitted\n" + data.title + "\n" + data.content); + setSubmitted(true); + }; + if(submitted) { + return ; + } else { + return ( +
+

Add a Todo

+ + setTitle(event.target.value) + } + /> + +