|
@@ -5,15 +5,20 @@ export default class ListItem extends React.Component {
|
|
|
let isCompleted = this.props.item.completed;
|
|
|
let isError = this.props.item.error;
|
|
|
|
|
|
- const Buttons = () => {
|
|
|
+ const Buttons = ({ completeButton = true, closeButton = true }) => {
|
|
|
return (
|
|
|
<>
|
|
|
- <span className="complete" onClick={this.complete.bind(this, this.props.item.id)}>
|
|
|
- ✔
|
|
|
- </span>
|
|
|
- <span className="close" onClick={this.delete.bind(this, this.props.item.id)}>
|
|
|
- ✕
|
|
|
- </span>
|
|
|
+ {completeButton ? (
|
|
|
+ <span className="complete" onClick={this.complete.bind(this, this.props.item.id)}>
|
|
|
+ ✔
|
|
|
+ </span>
|
|
|
+ ) : null}
|
|
|
+
|
|
|
+ {closeButton ? (
|
|
|
+ <span className="close" onClick={this.delete.bind(this, this.props.item.id)}>
|
|
|
+ ✕
|
|
|
+ </span>
|
|
|
+ ) : null}
|
|
|
</>
|
|
|
);
|
|
|
};
|
|
@@ -23,7 +28,7 @@ export default class ListItem extends React.Component {
|
|
|
<li className={"todo-item " + (isCompleted ? "complete " : "") + (isError ? "error " : "")}>
|
|
|
<span className="todo-item-number">{this.props.number}</span>
|
|
|
<span className="todo-item-text">{this.props.item.text}</span>
|
|
|
- {isCompleted || isError ? null : <Buttons />}
|
|
|
+ {isCompleted ? null : <Buttons completeButton={!isError} />}
|
|
|
</li>
|
|
|
</>
|
|
|
);
|