diff --git a/packages/component-wizard/src/components/WizardStep.js b/packages/component-wizard/src/components/WizardStep.js index 17b35ccd5e4b4c64316740a249ad2c7f5ac2ebab..4c369eeed7e3fa6cc041d5c0df786306b183025f 100644 --- a/packages/component-wizard/src/components/WizardStep.js +++ b/packages/component-wizard/src/components/WizardStep.js @@ -2,7 +2,6 @@ import React from 'react' import { get } from 'lodash' import classnames from 'classnames' import { ValidatedField, Button } from '@pubsweet/ui' -import { AuthorList } from 'pubsweet-components-faraday/src/components' import classes from './WizardStep.local.scss' import AutosaveIndicator from './AutosaveIndicator' @@ -67,7 +66,6 @@ export default ({ }, )} - <AuthorList /> <div className={classnames(classes.buttons)}> <Button onClick={isFirst ? () => history.push('/') : prevStep}> {isFirst diff --git a/packages/components-faraday/src/components/AuthorList/AuthorAdder.js b/packages/components-faraday/src/components/AuthorList/AuthorAdder.js index 5e9587c4091a115ba4184efcf983ec6648317597..30a5326787ed3e55fa3106c097cfd1e571b87c2e 100644 --- a/packages/components-faraday/src/components/AuthorList/AuthorAdder.js +++ b/packages/components-faraday/src/components/AuthorList/AuthorAdder.js @@ -83,7 +83,7 @@ export default compose( onSubmit: ( values, dispatch, - { authors, addAuthor, setEditMode, reset, match }, + { authors, addAuthor, setEditMode, setFormAuthors, reset, match }, ) => { const collectionId = get(match, 'params.project') const fragmentId = get(match, 'params.version') @@ -96,7 +96,9 @@ export default compose( }, collectionId, fragmentId, - ).then(() => { + ).then(author => { + const newAuthors = [...authors, author] + setFormAuthors(newAuthors) reset() setEditMode(false)() }) diff --git a/packages/components-faraday/src/components/AuthorList/AuthorList.js b/packages/components-faraday/src/components/AuthorList/AuthorList.js index 2b1db5af8cdb314fe5ef0682ada60ba9885a0196..06f4f7bb27e3fb4350c902059019f360770690db 100644 --- a/packages/components-faraday/src/components/AuthorList/AuthorList.js +++ b/packages/components-faraday/src/components/AuthorList/AuthorList.js @@ -38,6 +38,7 @@ const Authors = ({ editMode, setEditMode, editedAuthor, + setFormAuthors, ...rest }) => ( <div> @@ -48,12 +49,14 @@ const Authors = ({ editMode={editMode} match={match} setEditMode={setEditMode} + setFormAuthors={setFormAuthors} /> {editedAuthor > -1 ? ( <StaticList authors={authors} editComponent={AuthorEditor} editIndex={editedAuthor} + setFormAuthors={setFormAuthors} {...rest} /> ) : ( diff --git a/packages/components-faraday/src/components/SortableList/SortableList.js b/packages/components-faraday/src/components/SortableList/SortableList.js index b19cc9d884818c75682cf6637b6c499a4f2fc9f4..8b8baa48201415584cf33343d98b77370cf77c66 100644 --- a/packages/components-faraday/src/components/SortableList/SortableList.js +++ b/packages/components-faraday/src/components/SortableList/SortableList.js @@ -104,7 +104,7 @@ const SortableList = ({ <DecoratedItem dragHandle={dragHandle} index={i} - key={item.name || Math.random()} + key={item.id} listItem={listItem} moveItem={moveItem} {...item} diff --git a/packages/components-faraday/src/redux/authors.js b/packages/components-faraday/src/redux/authors.js index 7f5500564375f3e82a9145e4f13ece2a8990ee9e..5d78978e7bb1a7af87a82339bd95b81c20da24a3 100644 --- a/packages/components-faraday/src/redux/authors.js +++ b/packages/components-faraday/src/redux/authors.js @@ -1,4 +1,3 @@ -import { get } from 'lodash' import * as api from 'pubsweet-client/src/helpers/api' // constants @@ -6,16 +5,10 @@ export const SET_AUTHORS = 'authors/SET_AUTHORS' // actions export const addAuthor = (author, collectionId, fragmentId) => dispatch => - api - .create( - `/collections/${collectionId}/fragments/${fragmentId}/authors`, - author, - ) - .then(r => console.log('esposa', r)) -// .then(() => -// dispatch(actions.getFragment({ id: collectionId }, { id: fragmentId })), -// ) -// .then(({ fragment: { authors, id } }) => dispatch(setAuthors(authors, id))) + api.create( + `/collections/${collectionId}/fragments/${fragmentId}/authors`, + author, + ) // selectors