diff --git a/README.md b/README.md
index 86f9c092..9e3a72c9 100644
--- a/README.md
+++ b/README.md
@@ -48,14 +48,14 @@ In this project you will build an application that allows for todos to be added,
- **Build all components as class components. Find them inside `frontend/components`.**
- **Don't focus on styling. We want you to worry about function over form today.**
- Your todo list should display a list of todos, an input field, a submit button, and a button to filter out completed todos.
-- `` will hold all the data needed for this project.
- - All of your application data will be stored here on ``.
- - All of your `handler` functions should live here on ``.
-- `` receives your todos array and iterates over the list generating a new `` for each element in the array.
-- `` is a component that takes in the `todo` data and displays the task to the screen.
-- `
` will hold your input field and your `Add Todo` and `Clear Completed` buttons.
- - Your input field should take in user input, and allow a user to press `Enter` or click on the `Submit Button` to add a todo to your list.
- - Once a todo is submitted, the Todo List should re-render and show the added todo.
+- `` will hold all the data needed for this project. -- check
+ - All of your application data will be stored here on ``. -- check
+ - All of your `handler` functions should live here on ``. -- check
+- `` receives your todos array and iterates over the list generating a new `` for each element in the array. -- check
+- `` is a component that takes in the `todo` data and displays the task to the screen. -- check
+- `` will hold your input field and your `Add Todo` and `Clear Completed` buttons. --check
+ - Your input field should take in user input, and allow a user to press `Enter` or click on the `Submit Button` to add a todo to your list. -- check
+ - Once a todo is submitted, the Todo List should re-render and show the added todo. -- check
## Submission Format
diff --git a/frontend/components/App.js b/frontend/components/App.js
index 38b7a2f5..01b29411 100644
--- a/frontend/components/App.js
+++ b/frontend/components/App.js
@@ -1,10 +1,102 @@
import React from 'react'
+import TodoList from './TodoList'
+import Form from './Form'
+
+const theListArr = [
+ {
+ name: 'take out the trash',
+ id: Math.random(),
+ completed: false
+ },
+ {
+ name: 'wash the dishes',
+ id: Math.random(),
+ completed: false
+ },
+ {
+ name: 'go running',
+ id: Math.random(),
+ completed: false
+ }
+
+]
export default class App extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ theListArr: theListArr,
+ itemText: ''
+ }
+ }
+
+ toggleCompleted = (id) => {
+ this.setState({
+ theListArr: this.state.theListArr.map(list => {
+ if (id === list.id) {
+ return {
+ ...list, completed: !list.completed
+ }
+ }
+ return list
+ })
+ })
+ }
+
+ filterCompleted = () => {
+ this.setState({
+ theListArr: this.state.theListArr.filter(list => list.completed === false
+ )
+ })
+ }
+
+ addList = (name) => {
+ const newList = {
+ name: name,
+ id: Math.random(),
+ completed: false
+ }
+
+ const newListArr = [...this.state.theListArr, newList]
+
+ this.setState({
+ theListArr: newListArr
+ })
+ }
+
+ onSubmit = (e) => {
+ e.preventDefault()
+ this.addList(this.state.itemText)
+ this.setState({
+ itemText: ''
+ })
+ }
+
+
+
+ onChange = (e) => {
+ this.setState({
+ itemText: e.target.value
+ })
+ }
+
+
+
render() {
+
return (
- Todo App
+
+
)
}
diff --git a/frontend/components/Form.js b/frontend/components/Form.js
index 30fbc48d..3ae2258b 100644
--- a/frontend/components/Form.js
+++ b/frontend/components/Form.js
@@ -2,9 +2,18 @@ import React from 'react'
export default class Form extends React.Component {
render() {
+ console.log(this.props.theListArr.completed)
return (
- Form
+
)
}
diff --git a/frontend/components/Todo.js b/frontend/components/Todo.js
index ca86f981..ed3d9cd1 100644
--- a/frontend/components/Todo.js
+++ b/frontend/components/Todo.js
@@ -2,10 +2,20 @@ import React from 'react'
export default class Todo extends React.Component {
render() {
+ console.log(this.props.list.completed)
return (
)
}
}
+
+
+// {
+// this.props.theListArr.map(list => (
+//
+// {list.name}
+//
+// ))
+// }
diff --git a/frontend/components/TodoList.js b/frontend/components/TodoList.js
index 95410373..fd99309d 100644
--- a/frontend/components/TodoList.js
+++ b/frontend/components/TodoList.js
@@ -1,10 +1,18 @@
import React from 'react'
+import Todo from './Todo'
export default class TodoList extends React.Component {
render() {
return (
- TodoList
+ {
+ this.props.theListArr.map(list =>
+ )
+ }
)
}