diff --git a/README.md b/README.md index e3e663b6..8e854ad9 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ In this project you will build an application that allows for todos to be added, - Once a todo is submitted, the Todo List should re-render and show the added todo. ## Submission Format -- [ ] Only work on main. -- [ ] Make sure to push your code at regular intervals. -- [ ] Copy your github repo url and paste it into Canvas to submit your project \ No newline at end of file +- [ ] If this is your first time connecting a submission, authorize your github account within the codegrade assignment. +- [ ] Connect your fork to Codegrade using the "Connect Git" button. +- [ ] Find your newly created fork from the list and push your work to main. +- [ ] Check this video for details: www.youtube.com/watch?v=fC2BO7dI6IQ diff --git a/src/App.js b/src/App.js index 556b5fbc..3feffd5f 100644 --- a/src/App.js +++ b/src/App.js @@ -1,16 +1,86 @@ import React from 'react'; +import ReactDOM from 'react-dom'; + +import TodoForm from './components/TodoForm'; +import TodoList from './components/TodoList'; + +const checkList = [ + { + task: 'Organize Garage', + id: 1528817077286, + completed: false + }, + { + task: 'Bake Cookies', + id: 1528817084358, + completed: false + } +]; class App extends React.Component { - // you will need a place to store your state in this component. - // design `App` to be the parent component of your application. - // this component is going to take care of state, and any change handlers you need to work with your state + constructor() { + super(); + this.state = { + checkList: checkList + } + } + + handleClear = () => { + this.setState({ + ...this.state, + checkList: this.state.checkList.filter(item => !item.completed) + }); + } + + handleAddItems = (item) => { + const newItem = { + name: item, + id: Date.now, + completed: false + }; + + this.setState({ + ...this.state, + checkList: [...this.state.checkList, newItem] + }); + } + + handleToggle = (item) => { + this.setState({ + ...this.state, + checkList: this.state.checkList.map(list => { + if(list.id === item.id){ + return ({ + ...list, + completed: !list.completed + }) + } + return list; + }) + }) + } + render() { return ( -
{props.item.name}
+