From e56afa88691a790827d73d6eceda9f0cc678c4cb Mon Sep 17 00:00:00 2001 From: data Date: Wed, 10 Jul 2019 22:08:28 +0200 Subject: [PATCH] prettier --- src/App.js | 68 +++++++++++++++++--------------- src/components/article.js | 31 +++++++++------ src/components/articles.js | 60 +++++++++++++++------------- src/components/tags.js | 57 ++++++++++++++++---------- src/components/update-article.js | 12 +++--- 5 files changed, 132 insertions(+), 96 deletions(-) diff --git a/src/App.js b/src/App.js index f790de8..d62c5fe 100644 --- a/src/App.js +++ b/src/App.js @@ -8,11 +8,7 @@ import { selectArticle, } from './controllers/articles' -import { - addTag, - selectTag, - removeTag, -} from './controllers/tags' +import { addTag, selectTag, removeTag } from './controllers/tags' import { createTask, @@ -59,7 +55,7 @@ const defaultState = { newTask: '', newProject: '', project: {}, - newTag: '' + newTag: '', } class App extends React.Component { @@ -160,7 +156,15 @@ class App extends React.Component { const projects = await this.fetchProjects() const comments = await this.fetchComments() const votes = await this.fetchVotes() - await this.setState({ loading: false, articles, tags, tasks, projects, comments, votes }) + await this.setState({ + loading: false, + articles, + tags, + tasks, + projects, + comments, + votes, + }) } componentDidMount() { @@ -185,8 +189,7 @@ class App extends React.Component { renderError() { if (!this.state.error) { return
There was an error.
- } - else if (this.state.error.message === 'Network Error') { + } else if (this.state.error.message === 'Network Error') { alert(`Failed to reach backend at\n${this.state.error.config.url}.`) } else { return ( @@ -214,36 +217,39 @@ class App extends React.Component { ) } renderArticles() { - return ( ) } renderArticle() { - return (
) } renderUpdateArticle() { - return ( ) } diff --git a/src/components/article.js b/src/components/article.js index 20a80ec..2dc797e 100644 --- a/src/components/article.js +++ b/src/components/article.js @@ -11,23 +11,32 @@ class Article extends React.Component { render() { return (
- +

{this.state.title}

{this.state.text}
- - + +

Comments

    - {this.props.comments ? this.props.comments.map(comment=>( -
  • - {comment.text} -
  • - )) : "No comments yet." - } + {this.props.comments + ? this.props.comments.map(comment => ( +
  • + {comment.text} +
  • + )) + : 'No comments yet.'}
) diff --git a/src/components/articles.js b/src/components/articles.js index 93c5a82..910d11a 100644 --- a/src/components/articles.js +++ b/src/components/articles.js @@ -26,38 +26,42 @@ function Articles(props) { > {article.title}{' '} - - {props.tags && props.tags.filter(t => t.articleId === article.id).map(tag => ( - - )) - } + {props.tags && + props.tags + .filter(t => t.articleId === article.id) + .map(tag => ( + + ))} ))} -
  • -
    - - -
    +
  • +
    + + +
  • diff --git a/src/components/tags.js b/src/components/tags.js index f6b9ada..8a782f3 100644 --- a/src/components/tags.js +++ b/src/components/tags.js @@ -9,27 +9,42 @@ class Tags extends React.Component { render() { return (
    - - {this.props.tags && this.props.tags.filter(t => t.articleId === this.props.selectedArticleId).map(tag => ( - - + + + ))} +
    + + - - - ))} - - - -
    -
    - )} + + + ) + } } export default Tags diff --git a/src/components/update-article.js b/src/components/update-article.js index 8b4e99f..4668eda 100644 --- a/src/components/update-article.js +++ b/src/components/update-article.js @@ -8,8 +8,8 @@ class UpdateArticle extends React.Component { this.handleChange = this.handleChange.bind(this) if (!props.selectedArticleId) { - props.navigate('articles') - } + props.navigate('articles') + } } handleChange(e) { @@ -19,7 +19,9 @@ class UpdateArticle extends React.Component { render() { return (
    - +

    Article {this.state.id}

    @@ -29,7 +31,7 @@ class UpdateArticle extends React.Component { name="title" value={this.state.title} onChange={this.handleChange} - /> + />
    @@ -38,7 +40,7 @@ class UpdateArticle extends React.Component { className="form-control" name="text" rows="25" - value={this.state.text || ""} + value={this.state.text || ''} onChange={this.handleChange} />