From 24a4e424f869edc4107a15735442f2569374a215 Mon Sep 17 00:00:00 2001
From: yannis <yannisbarlas@gmail.com>
Date: Mon, 4 Dec 2017 20:47:48 +0200
Subject: [PATCH] prettier submit

---
 .../src/components/Confirm.js                 | 34 ++++++--
 .../src/components/Declarations.js            | 14 ++--
 .../src/components/Metadata.js                | 69 +++++++++-------
 .../component-submit/src/components/Notes.js  | 18 +++--
 .../component-submit/src/components/Submit.js | 52 ++++++++-----
 .../src/components/SubmitPage.js              | 78 +++++++++++--------
 .../src/components/Suggestions.js             | 54 ++++++-------
 .../src/components/SupplementaryFiles.js      | 16 ++--
 .../src/components/Validot.js                 |  3 +-
 .../src/components/Validots.js                | 23 +++---
 packages/component-submit/src/index.js        |  6 +-
 .../component-submit/styleguide.config.js     | 16 ++--
 12 files changed, 217 insertions(+), 166 deletions(-)

diff --git a/packages/component-submit/src/components/Confirm.js b/packages/component-submit/src/components/Confirm.js
index aa15e9a2d..1f03326d2 100644
--- a/packages/component-submit/src/components/Confirm.js
+++ b/packages/component-submit/src/components/Confirm.js
@@ -9,15 +9,39 @@ const Confirm = ({ toggleConfirming }) => (
         By submitting the manuscript, you agree to the following statements.
       </h1>
 
-      <p>The corresponding author confirms that all co-authors are included, and that everyone listed as a co-author agrees to that role and all the following requirements and acknowledgements.</p>
-
-      <p>The submission represents original work and that sources are given proper attribution. (The journal employs <a href="https://www.crossref.org/services/similarity-check/" target="_blank" rel="noopener noreferrer">CrossCheck</a> to compare submissions against a large and growing database of published scholarly content. If in the judgment of a senior editor a submission is genuinely suspected of plagiarism, it will be returned to the author(s) with a request for explanation.)</p>
+      <p>
+        The corresponding author confirms that all co-authors are included, and
+        that everyone listed as a co-author agrees to that role and all the
+        following requirements and acknowledgements.
+      </p>
+
+      <p>
+        The submission represents original work and that sources are given
+        proper attribution. (The journal employs{' '}
+        <a
+          href="https://www.crossref.org/services/similarity-check/"
+          target="_blank"
+          rel="noopener noreferrer"
+        >
+          CrossCheck
+        </a>{' '}
+        to compare submissions against a large and growing database of published
+        scholarly content. If in the judgment of a senior editor a submission is
+        genuinely suspected of plagiarism, it will be returned to the author(s)
+        with a request for explanation.)
+      </p>
 
       <p>The research was conducted in accordance with ethical principles.</p>
 
-      <p>There is a Data Accessibility Statement, containing information about the location of open data and materials, in the manuscript.</p>
+      <p>
+        There is a Data Accessibility Statement, containing information about
+        the location of open data and materials, in the manuscript.
+      </p>
 
-      <p>A conflict of interest statement is present in the manuscript, even if to state no conflicts of interest.</p>
+      <p>
+        A conflict of interest statement is present in the manuscript, even if
+        to state no conflicts of interest.
+      </p>
 
       <div className={classes.actions}>
         <Button type="submit" primary>
diff --git a/packages/component-submit/src/components/Declarations.js b/packages/component-submit/src/components/Declarations.js
index 2750835d5..0b8afc7ff 100644
--- a/packages/component-submit/src/components/Declarations.js
+++ b/packages/component-submit/src/components/Declarations.js
@@ -6,9 +6,7 @@ import { withJournal } from 'xpub-journal'
 import { required } from 'xpub-validators'
 import classes from './Declarations.local.scss'
 
-const DeclarationInput = input => (
-  <YesOrNo inline={true} {...input}/>
-)
+const DeclarationInput = input => <YesOrNo inline={true} {...input} />
 
 const Declarations = ({ journal }) => {
   return (
@@ -17,16 +15,16 @@ const Declarations = ({ journal }) => {
         <div
           key={question.id}
           id={`declarations.${question.id}`}
-          className={classnames(classes.section, classes.spread)}>
-          <div className={classes.legend}>
-            {question.legend}
-          </div>
+          className={classnames(classes.section, classes.spread)}
+        >
+          <div className={classes.legend}>{question.legend}</div>
 
           <ValidatedField
             name={question.id}
             required
             validate={[required]}
-            component={DeclarationInput}/>
+            component={DeclarationInput}
+          />
         </div>
       ))}
     </FormSection>
diff --git a/packages/component-submit/src/components/Metadata.js b/packages/component-submit/src/components/Metadata.js
index 342ae91c9..231811b4a 100644
--- a/packages/component-submit/src/components/Metadata.js
+++ b/packages/component-submit/src/components/Metadata.js
@@ -4,7 +4,14 @@ import { AbstractEditor, TitleEditor } from 'xpub-edit'
 import { CheckboxGroup, Menu, TextField, ValidatedField } from 'xpub-ui'
 import { withJournal } from 'xpub-journal'
 import classes from './Metadata.local.scss'
-import { join, required, minChars, maxChars, minSize, split } from 'xpub-validators'
+import {
+  join,
+  required,
+  minChars,
+  maxChars,
+  minSize,
+  split,
+} from 'xpub-validators'
 
 const minSize1 = minSize(1)
 const minChars20 = minChars(20)
@@ -12,37 +19,33 @@ const minChars100 = minChars(100)
 const maxChars500 = maxChars(500)
 const maxChars5000 = maxChars(5000)
 
-const TitleInput = input =>
-  <TitleEditor
-    placeholder="Enter the title…"
-    title="Title"
-    {...input}/>
+const TitleInput = input => (
+  <TitleEditor placeholder="Enter the title…" title="Title" {...input} />
+)
 
-const AbstractInput = input =>
+const AbstractInput = input => (
   <AbstractEditor
     title="Abstract"
     placeholder="Enter the abstract…"
-    {...input}/>
+    {...input}
+  />
+)
 
-const AuthorsInput = input =>
-  <TextField
-    placeholder="Enter author names…"
-    {...input}/>
+const AuthorsInput = input => (
+  <TextField placeholder="Enter author names…" {...input} />
+)
 
-const KeywordsInput = input =>
-  <TextField
-    placeholder="Enter keywords…"
-    {...input}/>
+const KeywordsInput = input => (
+  <TextField placeholder="Enter keywords…" {...input} />
+)
 
-const ArticleTypeInput = journal => input =>
-  <Menu
-    options={journal.articleTypes}
-    {...input}/>
+const ArticleTypeInput = journal => input => (
+  <Menu options={journal.articleTypes} {...input} />
+)
 
-const ArticleSectionInput = journal => input =>
-  <CheckboxGroup
-    options={journal.articleSections}
-    {...input}/>
+const ArticleSectionInput = journal => input => (
+  <CheckboxGroup options={journal.articleSections} {...input} />
+)
 
 const Metadata = ({ journal }) => (
   <FormSection name="metadata">
@@ -51,7 +54,8 @@ const Metadata = ({ journal }) => (
         name="title"
         required
         validate={[minChars20, maxChars500]}
-        component={TitleInput}/>
+        component={TitleInput}
+      />
     </div>
 
     <div className={classes.section} id="metadata.abstract">
@@ -59,7 +63,8 @@ const Metadata = ({ journal }) => (
         name="abstract"
         required
         validate={[minChars100, maxChars5000]}
-        component={AbstractInput}/>
+        component={AbstractInput}
+      />
     </div>
 
     <div className={classes.section} id="metadata.authors">
@@ -71,7 +76,8 @@ const Metadata = ({ journal }) => (
         format={join()}
         parse={split()}
         validate={[minSize1]}
-        component={AuthorsInput}/>
+        component={AuthorsInput}
+      />
     </div>
 
     <div className={classes.section} id="metadata.keywords">
@@ -83,7 +89,8 @@ const Metadata = ({ journal }) => (
         format={join()}
         parse={split()}
         validate={[minSize1]}
-        component={KeywordsInput}/>
+        component={KeywordsInput}
+      />
     </div>
 
     <div className={classes.section} id="metadata.articleType">
@@ -93,7 +100,8 @@ const Metadata = ({ journal }) => (
         name="articleType"
         required
         validate={[required]}
-        component={ArticleTypeInput(journal)}/>
+        component={ArticleTypeInput(journal)}
+      />
     </div>
 
     <div className={classes.section} id="metadata.articleSection">
@@ -103,7 +111,8 @@ const Metadata = ({ journal }) => (
         name="articleSection"
         required
         validate={[required]}
-        component={ArticleSectionInput(journal)}/>
+        component={ArticleSectionInput(journal)}
+      />
     </div>
   </FormSection>
 )
diff --git a/packages/component-submit/src/components/Notes.js b/packages/component-submit/src/components/Notes.js
index dbe2b5482..d19bb3046 100644
--- a/packages/component-submit/src/components/Notes.js
+++ b/packages/component-submit/src/components/Notes.js
@@ -5,17 +5,21 @@ import { ValidatedField } from 'xpub-ui'
 import { required } from 'xpub-validators'
 import classes from './Metadata.local.scss'
 
-const FundingInput = input =>
+const FundingInput = input => (
   <NoteEditor
     placeholder="Enter an acknowledgment…"
     title="Funding body acknowledgement (required)"
-    {...input}/>
+    {...input}
+  />
+)
 
-const InstructionsInput = input =>
+const InstructionsInput = input => (
   <NoteEditor
     placeholder="Enter instructions for the editor…"
     title="Special instructions (confidential)"
-    {...input}/>
+    {...input}
+  />
+)
 
 const Notes = () => (
   <FormSection name="notes">
@@ -23,13 +27,15 @@ const Notes = () => (
       <ValidatedField
         name="fundingAcknowledgement"
         validate={[required]}
-        component={FundingInput}/>
+        component={FundingInput}
+      />
     </div>
 
     <div className={classes.section} id="notes.specialInstructions">
       <ValidatedField
         name="specialInstructions"
-        component={InstructionsInput}/>
+        component={InstructionsInput}
+      />
     </div>
   </FormSection>
 )
diff --git a/packages/component-submit/src/components/Submit.js b/packages/component-submit/src/components/Submit.js
index 2fdfdad92..c150c7d0a 100644
--- a/packages/component-submit/src/components/Submit.js
+++ b/packages/component-submit/src/components/Submit.js
@@ -11,39 +11,53 @@ import Confirm from './Confirm'
 // import Validots from './Validots'
 import classes from './Submit.local.scss'
 
-const Submit = ({ project, version, valid, error, handleSubmit, uploadFile, confirming, toggleConfirming }) => (
-  <div className={classnames(classes.root, {
-    [classes.confirming]: confirming
-  })}>
-    <div className={classes.title}>
-      Submission information
-    </div>
+const Submit = ({
+  project,
+  version,
+  valid,
+  error,
+  handleSubmit,
+  uploadFile,
+  confirming,
+  toggleConfirming,
+}) => (
+  <div
+    className={classnames(classes.root, {
+      [classes.confirming]: confirming,
+    })}
+  >
+    <div className={classes.title}>Submission information</div>
 
     <div className={classes.intro}>
-      <div>We have ingested your manuscript. To access your manuscript in an editor, please <Link to={`/projects/${project.id}/versions/${version.id}/manuscript`}>view here</Link>.</div>
-      <div>To complete your submission, please answer the following questions.</div>
+      <div>
+        We have ingested your manuscript. To access your manuscript in an
+        editor, please{' '}
+        <Link to={`/projects/${project.id}/versions/${version.id}/manuscript`}>
+          view here
+        </Link>.
+      </div>
+      <div>
+        To complete your submission, please answer the following questions.
+      </div>
       <div>The answers will be automatically saved.</div>
     </div>
 
     <form onSubmit={handleSubmit}>
-      <Metadata/>
-      <Declarations/>
-      <Suggestions/>
-      <Notes/>
-      <SupplementaryFiles uploadFile={uploadFile}/>
+      <Metadata />
+      <Declarations />
+      <Suggestions />
+      <Notes />
+      <SupplementaryFiles uploadFile={uploadFile} />
 
       <div>
-        <Button
-          type="button"
-          primary
-          onClick={toggleConfirming}>
+        <Button type="button" primary onClick={toggleConfirming}>
           Submit your manuscript
         </Button>
       </div>
 
       {confirming && (
         <div className={classes.confirm}>
-          <Confirm toggleConfirming={toggleConfirming}/>
+          <Confirm toggleConfirming={toggleConfirming} />
         </div>
       )}
     </form>
diff --git a/packages/component-submit/src/components/SubmitPage.js b/packages/component-submit/src/components/SubmitPage.js
index b484e8981..6b0449db8 100644
--- a/packages/component-submit/src/components/SubmitPage.js
+++ b/packages/component-submit/src/components/SubmitPage.js
@@ -11,30 +11,37 @@ import Submit from './Submit'
 const onSubmit = (values, dispatch, { history, project, version }) => {
   // console.log('submit', values)
 
-  return dispatch(actions.updateFragment(project, {
-    id: version.id,
-    rev: version.rev,
-    submitted: new Date(),
-    ...values
-  })).then(() => {
-    return dispatch(actions.updateCollection({
-      id: project.id,
-      rev: project.rev,
-      status: 'submitted'
-    }))
-  }).then(() => {
-    history.push('/')
-  }).catch(error => {
-    if (error.validationErrors) {
-      throw new SubmissionError()
-    }
-  })
+  return dispatch(
+    actions.updateFragment(project, {
+      id: version.id,
+      rev: version.rev,
+      submitted: new Date(),
+      ...values,
+    }),
+  )
+    .then(() => {
+      return dispatch(
+        actions.updateCollection({
+          id: project.id,
+          rev: project.rev,
+          status: 'submitted',
+        }),
+      )
+    })
+    .then(() => {
+      history.push('/')
+    })
+    .catch(error => {
+      if (error.validationErrors) {
+        throw new SubmissionError()
+      }
+    })
 }
 
 // TODO: this is only here because prosemirror would save the title in the
 // metadata as html instead of plain text. we need to maybe find a better
 // position than here to perform this operation
-const stripHtml = (htmlString) => {
+const stripHtml = htmlString => {
   const temp = document.createElement('span')
   temp.innerHTML = htmlString
   return temp.textContent
@@ -44,12 +51,14 @@ const stripHtml = (htmlString) => {
 const onChange = (values, dispatch, { project, version }) => {
   values.metadata.title = stripHtml(values.metadata.title) // see TODO above
 
-  return dispatch(actions.updateFragment(project, {
-    id: version.id,
-    rev: version.rev,
-    // submitted: false,
-    ...values
-  }))
+  return dispatch(
+    actions.updateFragment(project, {
+      id: version.id,
+      rev: version.rev,
+      // submitted: false,
+      ...values,
+    }),
+  )
 
   // TODO: display a notification when saving/saving completes/saving fails
 }
@@ -57,7 +66,10 @@ const onChange = (values, dispatch, { project, version }) => {
 export default compose(
   ConnectPage(({ match }) => [
     actions.getCollection({ id: match.params.project }),
-    actions.getFragment({ id: match.params.project }, { id: match.params.version })
+    actions.getFragment(
+      { id: match.params.project },
+      { id: match.params.version },
+    ),
   ]),
   connect(
     (state, { match }) => {
@@ -67,31 +79,31 @@ export default compose(
       return { project, version }
     },
     {
-      uploadFile
-    }
+      uploadFile,
+    },
   ),
   withProps(({ version }) => {
     const paths = ['metadata', 'declarations', 'suggestions', 'notes', 'files']
 
     return {
-      initialValues: pick(version, paths)
+      initialValues: pick(version, paths),
     }
   }),
   reduxForm({
     form: 'submit',
     // enableReinitialize: true,
     onSubmit,
-    onChange: debounce(onChange, 1000, { maxWait: 5000 })
+    onChange: debounce(onChange, 1000, { maxWait: 5000 }),
   }),
   withState('confirming', 'setConfirming', false),
   withHandlers({
-    toggleConfirming: ({valid, setConfirming, handleSubmit}) => () => {
+    toggleConfirming: ({ valid, setConfirming, handleSubmit }) => () => {
       if (valid) {
         setConfirming(confirming => !confirming)
       } else {
         // trigger dummy submit to mark all fields as touched
         handleSubmit(() => {})()
       }
-    }
-  })
+    },
+  }),
 )(Submit)
diff --git a/packages/component-submit/src/components/Suggestions.js b/packages/component-submit/src/components/Suggestions.js
index eab868361..c416eee36 100644
--- a/packages/component-submit/src/components/Suggestions.js
+++ b/packages/component-submit/src/components/Suggestions.js
@@ -7,33 +7,27 @@ import classes from './Suggestions.local.scss'
 const joinComma = join(',')
 const splitComma = split(',')
 
-const SuggestedReviewerInput = input =>
-  <TextField
-    placeholder="Add reviewer names"
-    {...input}/>
-
-const OpposedReviewerInput = input =>
-  <TextField
-    placeholder="Add reviewer names"
-    {...input}/>
-
-const SuggestedEditorInput = input =>
-  <TextField
-    placeholder="Add editor names"
-    {...input}/>
-
-const OpposedEditorInput = input =>
-  <TextField
-    placeholder="Add editor names"
-    {...input}/>
+const SuggestedReviewerInput = input => (
+  <TextField placeholder="Add reviewer names" {...input} />
+)
+
+const OpposedReviewerInput = input => (
+  <TextField placeholder="Add reviewer names" {...input} />
+)
+
+const SuggestedEditorInput = input => (
+  <TextField placeholder="Add editor names" {...input} />
+)
+
+const OpposedEditorInput = input => (
+  <TextField placeholder="Add editor names" {...input} />
+)
 
 const Suggestions = () => (
   <FormSection name="suggestions">
     <div className={classes.section} id="suggestions.reviewers">
       <FormSection name="reviewers">
-        <div className={classes.legend}>
-          Suggested or opposed reviewers
-        </div>
+        <div className={classes.legend}>Suggested or opposed reviewers</div>
 
         <div>
           <div className={classes.sublegend}>Suggested reviewers</div>
@@ -42,7 +36,8 @@ const Suggestions = () => (
             name="suggested"
             format={joinComma}
             parse={splitComma}
-            component={SuggestedReviewerInput}/>
+            component={SuggestedReviewerInput}
+          />
         </div>
 
         <div>
@@ -52,16 +47,15 @@ const Suggestions = () => (
             name="opposed"
             format={joinComma}
             parse={splitComma}
-            component={OpposedReviewerInput}/>
+            component={OpposedReviewerInput}
+          />
         </div>
       </FormSection>
     </div>
 
     <div className={classes.section} id="suggestions.editors">
       <FormSection name="editors">
-        <div className={classes.legend}>
-          Suggested or opposed editors
-        </div>
+        <div className={classes.legend}>Suggested or opposed editors</div>
 
         <div>
           <div className={classes.sublegend}>Suggested editors</div>
@@ -70,7 +64,8 @@ const Suggestions = () => (
             name="suggested"
             format={joinComma}
             parse={splitComma}
-            component={SuggestedEditorInput}/>
+            component={SuggestedEditorInput}
+          />
         </div>
 
         <div>
@@ -80,7 +75,8 @@ const Suggestions = () => (
             name="opposed"
             format={joinComma}
             parse={splitComma}
-            component={OpposedEditorInput}/>
+            component={OpposedEditorInput}
+          />
         </div>
       </FormSection>
     </div>
diff --git a/packages/component-submit/src/components/SupplementaryFiles.js b/packages/component-submit/src/components/SupplementaryFiles.js
index 9db16bb4e..2330f2543 100644
--- a/packages/component-submit/src/components/SupplementaryFiles.js
+++ b/packages/component-submit/src/components/SupplementaryFiles.js
@@ -3,22 +3,18 @@ import { FormSection } from 'redux-form'
 import { Supplementary, ValidatedField } from 'xpub-ui'
 import classes from './Metadata.local.scss'
 
-const FileInput = uploadFile => input =>
-  <Supplementary
-    uploadFile={uploadFile}
-    {...input}/>
+const FileInput = uploadFile => input => (
+  <Supplementary uploadFile={uploadFile} {...input} />
+)
 
 const SupplementaryFiles = ({ uploadFile }) => (
   <FormSection name="files">
     <div className={classes.section} id="files.supplementary">
-      <div
-        className={classes.label}
-        htmlFor="supplementary">Upload supplementary materials
+      <div className={classes.label} htmlFor="supplementary">
+        Upload supplementary materials
       </div>
 
-      <ValidatedField
-        name="supplementary"
-        component={FileInput(uploadFile)}/>
+      <ValidatedField name="supplementary" component={FileInput(uploadFile)} />
     </div>
   </FormSection>
 )
diff --git a/packages/component-submit/src/components/Validot.js b/packages/component-submit/src/components/Validot.js
index 4ffd9184a..25a73a3db 100644
--- a/packages/component-submit/src/components/Validot.js
+++ b/packages/component-submit/src/components/Validot.js
@@ -14,7 +14,8 @@ const Validot = ({ input, meta, message }) => (
       [classes.warning]: meta.warning,
     })}
     // message={message}
-    onClick={() => scrollIntoView(input.name)}/>
+    onClick={() => scrollIntoView(input.name)}
+  />
 )
 
 export default Validot
diff --git a/packages/component-submit/src/components/Validots.js b/packages/component-submit/src/components/Validots.js
index e5961d29c..1a19c0535 100644
--- a/packages/component-submit/src/components/Validots.js
+++ b/packages/component-submit/src/components/Validots.js
@@ -10,24 +10,19 @@ import { connect } from 'react-redux'
 
 export const Validots = ({ form, valid, handleSubmit }) => (
   <div>
-    {form.registeredFields && (
+    {form.registeredFields &&
       map(form.registeredFields, field => (
         <div key={field.name}>
-          <Field
-            name={field.name}
-            component={Validot}/>
+          <Field name={field.name} component={Validot} />
         </div>
-      ))
-    )}
+      ))}
 
-    <button
-      onClick={handleSubmit}
-      disabled={!valid}>Submit</button>
+    <button onClick={handleSubmit} disabled={!valid}>
+      Submit
+    </button>
   </div>
 )
 
-export default connect(
-  state => ({
-    form: state.form.submit
-  })
-)(Validots)
+export default connect(state => ({
+  form: state.form.submit,
+}))(Validots)
diff --git a/packages/component-submit/src/index.js b/packages/component-submit/src/index.js
index 0225ff41f..6f1f42a64 100644
--- a/packages/component-submit/src/index.js
+++ b/packages/component-submit/src/index.js
@@ -1,7 +1,5 @@
 module.exports = {
   frontend: {
-    components: [
-      () => require('./components')
-    ]
-  }
+    components: [() => require('./components')],
+  },
 }
diff --git a/packages/component-submit/styleguide.config.js b/packages/component-submit/styleguide.config.js
index ef2282aa0..b119cf91b 100644
--- a/packages/component-submit/styleguide.config.js
+++ b/packages/component-submit/styleguide.config.js
@@ -1,20 +1,22 @@
 module.exports = {
   title: 'xpub submit style guide',
   styleguideComponents: {
-    StyleGuideRenderer: require.resolve('xpub-styleguide/src/components/StyleGuideRenderer'),
-    Wrapper: require.resolve('xpub-styleguide/src/components/Wrapper')
+    StyleGuideRenderer: require.resolve(
+      'xpub-styleguide/src/components/StyleGuideRenderer',
+    ),
+    Wrapper: require.resolve('xpub-styleguide/src/components/Wrapper'),
   },
   context: {
-    faker: 'faker'
+    faker: 'faker',
   },
   skipComponentsWithoutExample: true,
   serverPort: 6064,
   theme: {
     fontFamily: {
-      base: '"Fira Sans", sans-serif'
+      base: '"Fira Sans", sans-serif',
     },
     color: {
-      link: 'cornflowerblue'
-    }
-  }
+      link: 'cornflowerblue',
+    },
+  },
 }
-- 
GitLab