Skip to content

Commit

Permalink
get todos from api
Browse files Browse the repository at this point in the history
  • Loading branch information
mosufy committed Oct 27, 2016
1 parent 05e75ff commit b839878
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 20 deletions.
15 changes: 5 additions & 10 deletions public/js/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -32325,11 +32325,6 @@
value: function componentWillMount() {
this.props.getTodos(this.props.auth.accessToken);
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
console.log('ToDo list updated');
}
}, {
key: 'render',
value: function render() {
Expand Down Expand Up @@ -32557,8 +32552,6 @@
value: function render() {
var _this2 = this;

var toggleCompleted = this.props.toggleCompleted;

if (this.props.items.length == 0) {
return _react2.default.createElement(
'div',
Expand All @@ -32582,13 +32575,15 @@
}

var itemText = item.text;
var defaultChecked;

if (item.completed) {
itemText = _react2.default.createElement(
'del',
null,
item.text
);
defaultChecked = 'defaultChecked';
}

return _react2.default.createElement(
Expand All @@ -32597,7 +32592,7 @@
_react2.default.createElement(
'label',
null,
_react2.default.createElement('input', { id: item.id, type: 'checkbox', value: item.id, onClick: toggleCompleted, defaultChecked: item.completed ? 'defaultChecked' : '' }),
_react2.default.createElement('input', { id: item.id, type: 'checkbox', value: item.id, onClick: _this2.props.toggleCompleted, defaultChecked: defaultChecked }),
itemText
)
);
Expand Down Expand Up @@ -32963,9 +32958,9 @@
var items = [];
for (var i = 0; i < todos.length; i++) {
items.push({
id: todos[i].attributes.id,
id: todos[i].attributes.uid,
text: todos[i].attributes.title,
completed: todos[i].attributes.isCompleted
completed: todos[i].attributes.is_completed
});
}
return items;
Expand Down
2 changes: 1 addition & 1 deletion public/js/bundle.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions resources/app/components/MyTodoItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import React from 'react';

export default class MyTodoItems extends React.Component {
render() {
var toggleCompleted = this.props.toggleCompleted;

if (this.props.items.length == 0) {
return (
<div>
Expand All @@ -33,17 +31,19 @@ export default class MyTodoItems extends React.Component {
}

var itemText = item.text;
var defaultChecked;

if (item.completed) {
itemText = (
<del>{item.text}</del>
);
defaultChecked = 'defaultChecked';
}

return (
<div className="checkbox" key={item.id}>
<label>
<input id={item.id} type="checkbox" value={item.id} onClick={toggleCompleted} defaultChecked={item.completed ? 'defaultChecked' : ''}/>{itemText}
<input id={item.id} type="checkbox" value={item.id} onClick={this.props.toggleCompleted} defaultChecked={defaultChecked}/>{itemText}
</label>
</div>
);
Expand Down
4 changes: 0 additions & 4 deletions resources/app/containers/DashboardContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ class DashboardContainer extends React.Component {
this.props.getTodos(this.props.auth.accessToken);
}

componentDidMount() {
console.log('ToDo list updated');
}

render() {
return (
<MyTodo items={this.props.todos}
Expand Down
4 changes: 2 additions & 2 deletions resources/app/reducers/todos.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const todos = (state = [], action) => {
var items = [];
for (var i = 0; i < todos.length; i++) {
items.push({
id: todos[i].attributes.id,
id: todos[i].attributes.uid,
text: todos[i].attributes.title,
completed: todos[i].attributes.isCompleted
completed: todos[i].attributes.is_completed
});
}
return items;
Expand Down

0 comments on commit b839878

Please sign in to comment.