Skip to content

Commit d67b1b8

Browse files
committed
prettify todos container
1 parent 81feb7f commit d67b1b8

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

common/js/containers/Todos/index.js

+25-16
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,28 @@ import PropTypes from 'prop-types';
33
import { connect } from 'react-redux';
44
import { Helmet } from 'react-helmet';
55
import { addTodo, toggleTodo, removeTodo, fetchTodos } from 'actions/todos';
6-
import { Container, Header, Checkbox, List, Button, Form } from 'semantic-ui-react';
6+
import {
7+
Container,
8+
Header,
9+
Checkbox,
10+
List,
11+
Button,
12+
Form
13+
} from 'semantic-ui-react';
714
import classnames from 'classnames';
815
import css from './index.scss';
916

1017
const cx = classnames.bind(css);
1118

1219
class TodosContainer extends Component {
20+
static fetchData = ({ store }) => {
21+
return store.dispatch(fetchTodos());
22+
};
1323

1424
static propTypes = {
1525
todos: PropTypes.object.isRequired,
1626
dispatch: PropTypes.func.isRequired
17-
}
27+
};
1828

1929
state = { todoText: '' };
2030

@@ -26,30 +36,30 @@ class TodosContainer extends Component {
2636
}
2737
}
2838

29-
submitTodo = (ev) => {
39+
submitTodo = ev => {
3040
const { dispatch } = this.props;
3141
const { todoText } = this.state;
3242

3343
ev.preventDefault();
3444
dispatch(addTodo(todoText));
3545
this.setState({ todoText: '' });
36-
}
46+
};
3747

38-
checkTodo = (id) => {
48+
checkTodo = id => {
3949
const { dispatch } = this.props;
4050

4151
dispatch(toggleTodo(id));
42-
}
52+
};
4353

44-
removeTodo = (id) => {
54+
removeTodo = id => {
4555
const { dispatch } = this.props;
4656

4757
dispatch(removeTodo(id));
48-
}
58+
};
4959

50-
onTodoChange = (ev) => {
60+
onTodoChange = ev => {
5161
this.setState({ todoText: ev.target.value });
52-
}
62+
};
5363

5464
render() {
5565
const { todos: { todos } } = this.props;
@@ -81,7 +91,9 @@ class TodosContainer extends Component {
8191
onChange={() => this.checkTodo(id)}
8292
/>
8393
</List.Content>
84-
<List.Content className={cx(css.text, { [css.completed]: completed })}>
94+
<List.Content
95+
className={cx(css.text, { [css.completed]: completed })}
96+
>
8597
{text}
8698
</List.Content>
8799
</List.Item>
@@ -94,7 +106,8 @@ class TodosContainer extends Component {
94106
onChange={this.onTodoChange}
95107
value={todoText}
96108
type="text"
97-
placeholder="Add a todo..." />
109+
placeholder="Add a todo..."
110+
/>
98111
<Form.Button content="Add" icon="plus" />
99112
</Form.Group>
100113
</Form>
@@ -103,10 +116,6 @@ class TodosContainer extends Component {
103116
}
104117
}
105118

106-
TodosContainer.fetchData = ({ store }) => {
107-
return store.dispatch(fetchTodos());
108-
};
109-
110119
const mapStateToProps = ({ todos }) => ({ todos });
111120

112121
export default connect(mapStateToProps)(TodosContainer);

0 commit comments

Comments
 (0)