File tree 8 files changed +11431
-0
lines changed 8 files changed +11431
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React , { Component } from 'react' ;
2
+ // import logo from './logo.svg';
3
+ import Header from './components/header' ;
4
+ import Text from './components/WelcomeText/Text' ;
5
+ import TaskBar from './components/taskBar' ;
6
+ import TaskList from './components/taskList' ;
7
+ import TaskCount from './components/taskCount' ;
8
+ import './App.css' ;
9
+
10
+ class App extends Component {
11
+ render ( ) {
12
+ return (
13
+ < div className = "App" >
14
+ < Header />
15
+ < Text />
16
+ < TaskBar />
17
+ < TaskCount />
18
+ < TaskList />
19
+ </ div >
20
+ ) ;
21
+ }
22
+ }
23
+
24
+ export default App ;
Original file line number Diff line number Diff line change
1
+ import React , { Component } from 'react' ;
2
+
3
+ class Text extends Component {
4
+ render ( ) {
5
+ return (
6
+ < p > Hello! Add your tasks at input</ p >
7
+ )
8
+ }
9
+ } ;
10
+
11
+ export default Text ;
Original file line number Diff line number Diff line change
1
+ import React , { Component } from 'react' ;
2
+
3
+ export default class Header extends Component {
4
+ render ( ) {
5
+ return (
6
+ < h1 class = "m-3" > Todo Application</ h1 >
7
+ ) ;
8
+ }
9
+ }
Original file line number Diff line number Diff line change
1
+ import React , { Component } from 'react' ;
2
+ import { connect } from 'react-redux' ;
3
+ import { bindActionCreators } from "redux" ;
4
+ import { deleteTask } from "../../actions/" ;
5
+
6
+ class Task extends Component {
7
+ render ( ) {
8
+ return (
9
+ < tr >
10
+ < td >
11
+ { this . props . task }
12
+ </ td >
13
+ < td >
14
+ < button onClick = { ( ) => { this . props . deleteTask ( this . props . id ) } } class = "btn btn-sm btn-danger" > Delete</ button >
15
+ </ td >
16
+ </ tr >
17
+ ) ;
18
+ }
19
+ }
20
+
21
+ function mapDispatchToProps ( dispatch ) {
22
+ return bindActionCreators ( { deleteTask } , dispatch ) ;
23
+ }
24
+
25
+ export default connect ( ( ) => { } , mapDispatchToProps ) ( Task ) ;
Original file line number Diff line number Diff line change
1
+ import React , { Component } from 'react' ;
2
+ import { connect } from 'react-redux' ;
3
+ import { bindActionCreators } from "redux" ;
4
+ import { addTask } from "../../actions/" ;
5
+
6
+ class TaskBar extends Component {
7
+ render ( ) {
8
+ return (
9
+ < div class = "container" >
10
+ < form class = "form-inline" onSubmit = { ( ) => this . props . addTask ( this . refs . task . value ) } >
11
+ < div class = "form-group mb-3" >
12
+ < label for = "task" class = "sr-only" > New Task</ label >
13
+ < input type = "text" name = "task" ref = "task" class = "form-control" placeholder = "add your tasks here" />
14
+ </ div >
15
+ < button type = "submit" class = "btn btn-primary mb-3 ml-2" > Add Task</ button >
16
+ </ form >
17
+ </ div >
18
+ ) ;
19
+ }
20
+ }
21
+
22
+ function mapDispatchToProps ( dispatch ) {
23
+ return bindActionCreators ( { addTask } , dispatch ) ;
24
+ }
25
+
26
+ export default connect ( ( ) => { } , mapDispatchToProps ) ( TaskBar ) ;
Original file line number Diff line number Diff line change
1
+ import React , { Component } from 'react' ;
2
+ import { connect } from 'react-redux' ;
3
+
4
+ class TaskCount extends Component {
5
+ render ( ) {
6
+ return (
7
+ < div class = "container text-left" >
8
+ < p >
9
+ < b > Total tasks:</ b >
10
+ < span class = "ml-2" > { this . props . tasks . length } </ span >
11
+ </ p >
12
+ </ div >
13
+ ) ;
14
+ }
15
+ }
16
+
17
+ function mapStateToProps ( state ) {
18
+ let { tasks } = state
19
+ return { tasks }
20
+ }
21
+
22
+ export default connect ( mapStateToProps ) ( TaskCount ) ;
Original file line number Diff line number Diff line change
1
+ import React , { Component } from 'react' ;
2
+ import { connect } from 'react-redux' ;
3
+ import Task from "../task" ;
4
+
5
+ class TaskList extends Component {
6
+ render ( ) {
7
+ return (
8
+ < div class = "container" >
9
+ < table class = "table table-hover table-bordered table-sm" >
10
+ < thead >
11
+ < tr >
12
+ < th > Tasks</ th >
13
+ < th > Actions</ th >
14
+ </ tr >
15
+ </ thead >
16
+ < tbody >
17
+ { this . props . tasks . map ( ( task , index ) => < Task key = { index } task = { task } /> ) }
18
+ </ tbody >
19
+ </ table >
20
+ </ div >
21
+ ) ;
22
+ }
23
+ }
24
+
25
+ function mapStateToProps ( state ) {
26
+ let { tasks } = state
27
+ return { tasks }
28
+ }
29
+
30
+ export default connect ( mapStateToProps ) ( TaskList ) ;
You can’t perform that action at this time.
0 commit comments