diff --git a/packages/component-faraday-ui/src/gridItems/Item.js b/packages/component-faraday-ui/src/gridItems/Item.js index 6680ce0f5c4b9b69acf6fdf7372319c15fe8223d..a784d8561d2aaa1ee4e87ab87559efbeb79d650c 100644 --- a/packages/component-faraday-ui/src/gridItems/Item.js +++ b/packages/component-faraday-ui/src/gridItems/Item.js @@ -20,15 +20,15 @@ const Item = styled.div.attrs({ ` Item.propTypes = { - /** defines how flex items are laid out along the axis */ + /** Defines how flex items are laid out along the secondary axis. */ alignItems: PropTypes.string, - /** is a sub-property for flexbox that sets flexible length on flexible items */ + /** How much space should this item take relative to the other items. */ flex: PropTypes.number, - /** specifies how flex items are placed in the flex container */ + /** Sets the flex direction. If true items are layed out in a column. */ vertical: PropTypes.bool, - /** sets whether flex items are forced onto one line or can wrap ont multiple ones */ + /** Sets whether flex items are forced onto one line or can wrap on multiple ones. */ flexWrap: PropTypes.string, - /** specifies how the browser distributes space between and around items along the axis */ + /** Specifies alignment along the main axis. */ justify: PropTypes.string, } diff --git a/packages/component-faraday-ui/src/gridItems/Row.js b/packages/component-faraday-ui/src/gridItems/Row.js index 4afa71d265da88d1ccbb472762d86790a55427ad..54c7faacf72fd25255536cac2a2e5e5b0de04c7b 100644 --- a/packages/component-faraday-ui/src/gridItems/Row.js +++ b/packages/component-faraday-ui/src/gridItems/Row.js @@ -23,15 +23,15 @@ const Row = styled.div.attrs({ ` Row.propTypes = { - /** defines how flex items are laid out along the axis */ + /** Defines how flex items are laid out along the seconday axis. */ alignItems: PropTypes.string, - /** defines the background color */ - backgroundColor: PropTypes.string, - /** specifies how the browser distributes space between and around items along the axis */ + /** Defines the background color. */ + bgColor: PropTypes.string, + /** Sets whether flex items are forced onto one line or can wrap on multiple ones. */ flexWrap: PropTypes.string, - /** specifies how the browser distributes space between and around items along the axis */ + /** Specifies alignment along the main axis. */ justifyContent: PropTypes.string, - /** specifies the height of the item */ + /** Set the height in pixels. */ height: PropTypes.string, } diff --git a/packages/component-faraday-ui/src/helpers/README.md b/packages/component-faraday-ui/src/helpers/README.md new file mode 100644 index 0000000000000000000000000000000000000000..588a016a342b676e6bb207f4a2f87fe92da8e694 --- /dev/null +++ b/packages/component-faraday-ui/src/helpers/README.md @@ -0,0 +1,320 @@ +## Hindawi Helpers + +_Utility HOCs_ + +* [withCountries](#withcountries) +* [withFetching](#withfetching) +* [withFileDownload](#withfiledownload) +* [withFilePreview](#withfilepreview) +* [withPagination](#withpagination) +* [withRoles](#withroles) +* [withZipDownload](#withzipdownload) + +_HOCs used for files drag and drop_ + +* [withFileSectionDrop](#withfilesectiondrop) +* [withNativeFileDrop](#withnativefiledrop) + +_Utility functions_ + +* [handleError](#handleerror) + +# Utility HOCs + +## withCountries + +Injects `countries` and `countryLabel` as props. + +### withCountries props + +| Name | Type | Description | +| :----------- | :--------------------------------- | :-------------------------------------------------- | +| countries | `[{value: string, label: string}]` | the list of countries | +| countryLabel | `(code: string) => string` | get the name of the country with the specified code | + +```js +import { Menu } from '@pubsweet/ui' +import { withCountries } from 'pubsweet-component-faraday-ui' + +const Wrapped = ({ countries, countryLabel }) => ( + <div> + <Menu options={countries} placeholder="Select a country" /> + + <span>Selected country: {countryLabel('RO')}</span> + </div> +) + +export default withCountries(Wrapped) +``` + +## withFetching + +Injects `isFetching`, `fetchingError`, `setFetching`, `toggleFetching`, `setError` and `clearError` as props. + +### withFetching props + +| Name | Type | Description | +| :------------- | :----------------------- | :---------------------------------------------------------- | +| isFetching | `bool` | Pending async operation sattus | +| fetchingError | `fetchingError` | Value representing the error | +| setFetching | `(value: bool) => any` | Function for setting the `isFetching` value | +| toggleFetching | `(value: bool) => any` | Function that toggles the current value of `isFetching` | +| setError | `(error: string) => any` | Function that sets `fetchingError` | +| clearError | `() => any` | Function that resets `fetchingError` to it's original value | + +```js +import { withFetching } from 'pubsweet-component-faraday-ui' + +const Wrapped = ({ isFetching, fetchingError, setFetching, toggleFetching }) => ( + <div> + {isFetching && <span>I am fetching</span>} + <span>{`The error: ${fetchingError}`</span> + <button onClick={() => setFetching(true)}>Set fetching true</button> + <button onClick={() => setFetching(false)}>Set fetching false</button> + <button onClick={toggleFetching}>Toggle fetching</button> + </div> +) + +export default withFetching(Wrapped) +``` + +## withFileDownload + +Injects `downloadFile` as a prop. + +### withFileDownload props + +| Name | Type | Description | +| :----------- | :------------------------------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------- | +| downloadFile | `(file: {id: string, name: string}) => any` | Downloads the file specified as a parameter. The wrapped component should have the authentication token in a prop called `token` in order for this to work. | + +```js +import { FileItem, withFileDownload } from 'pubsweet-component-faraday-ui' + +const file = { + id: 'myfile', + name: 'myfile.pdf', + size: 100231, +} + +const Wrapped = ({ downloadFile }) => ( + <div> + <FileItem item={file} onDownload={downloadfile} /> + </div> +) + +export default withFileDownload(Wrapped) +``` + +## withFilePreview + +Generate a securized file URL and preview it in a new tab. Injects `previewFile` as a prop. + +This HOC assumes the following props are present on the wrapped component: + +| Name | Type | Description | +| :----------- | :--------------------------------------------- | :------------------------------------------------ | +| getSignedURL | `(id: string) => Promise({signedURL: string})` | Async call that returns the securized S3 file url | + +### withFilePreviewProps + +| Name | Type | Description | +| :---------- | :--------------------------------- | :--------------------------------------------------------------------------- | +| previewFile | `(file: {id: string, ...}) => any` | Opens the file preview in a new tab (only possible for PDF files and images) | + +```javascript +import { withProps } from 'recompose' +import { FileItem, withFilePreview Wrapped} from 'pubsweet-component-faraday-ui' + +const file = { + id: 'myfile', + name: 'myfile.pdf', + size: 100231, +} + +const Wrapped = ({ previewFile }) => ( + <div> + <FileItem item={file} onPreview={previewFile} /> + </div> +) + +export default withFilePreview(Wrapped) +``` + +## withPagination + +Injects `page`, `itemsPerPage`, `toFirst`, `nextPage`, `toLast`, `prevPage`, `changeItemsPerPage`, `hasMore`, `maxItems` and `paginatedItems` as props. + +### withPagination props + +| Name | Type | Description | +| :----------------- | :---------------------------------------------------------- | :------------------------------------ | +| page | `number` | Current page. | +| itemsPerPage | `number` | Number of items to be shown per page. | +| maxItems | `number` | Total number of items. | +| maxItems | `number` | Total number of items. | +| hasMore | `bool` | If we're not at the last page yet. | +| paginatedItems | `[any]` | Slice of the original items. | +| toFirst | `() => { page: number }` | Go to the first page. | +| toLast | `() => { page: number }` | Go to the last page. | +| nextPage | `() => { page: number }` | Move to the next page. | +| prevPage | `() => { page: number }` | Move to the previous page. | +| changeItemsPerPage | `e: HTMLInputEvent => {page: number, itemsPerPage: number}` | Change the number of items per page. | + +```js +import { withPagination } from 'pubsweet-component-faraday-ui' + +const Wrapped = ({ page, nextPage, prevPage, paginatedItems, changeItemsPerPage }) => ( + <div> + <span>Page {page}</span> + <button onClick={prevPage}>Prev page</button> + <button onClick={nextPage}>Next page</button> + <input type="text" onChange={changeItemsPerPage} /> + <div> + { + paginatedItems.map(p => <span>{p}<span>) + } + </div> + </div> +) + +export default withPagination(Wrapped) +``` + +## withRoles + +Injects the `roles` array as a prop. The roles are parsed from the journal config files. + +### withRoles props + +| Name | Type | Description | +| :---- | :--------------------------------- | :---------------------- | +| roles | `[{value: string, label: string}]` | An array of user roles. | + +```js +import { Menu } from '@pubsweet/ui' +import { withRoles } from 'pubsweet-component-faraday-ui' + +const Wrapped = ({ roles }) => <Menu options={roles} /> + +export default withRoles(Wrapped) +``` + +## withZipDownload + +Downloads all the files of a fragment as a zip archive. Injects the `downloadFiles` function as a prop. + +This HOCs assumes the following props are present on the wrapped component: + +| Name | Type | Description | +| :---------- | :--------------------- | :----------------------------------------------------- | +| token | `string` | Authentication token (used to authorize this request). | +| isReviewer | `bool` | If the user is reviewer. | +| fragmentId | `string` | Id of the fragment whose files we want to download. | +| setFetching | `(value: bool) => any` | Callback to set a fetching status. | +| archiveName | `string` | Name of the outputted archive file. | + +### withZipDownload props + +| Name | Type | Description | +| :------------ | :---------------- | :----------------------------------------- | +| downloadFiles | `strin() => anyg` | Download all the fragment's file as a zip. | + +# Files drag and drop + +## withFileSectionDrop + +HOC used to provide drop functionality to the `FileSection` component. It's main purpose is to change a file from one list to another. This is usually done in a callback called `changeList` that should be provided to the wrapped component. + +This HOC assumes the wrapped component has the following props: + +| Name | Type | Description | +| :-------------------- | :-------------------------------------------------------------- | :------------------------------------------------- | +| files | `[{id: string, ...}]` | List of files passed to the wrapped component. | +| setError | `(error: string) => any` | Error setting callback. | +| listId | `string` | Current list id. | +| allowedFileExtensions | `[string]` | Allowed file types. | +| maxFiles | `number` | Maximum number of files allowed. | +| changeList | `(fromListId: string, toListId: string: fileId: string) => any` | Callback fired when moving the file to a new list. | + +```js +import { compose, withHandler, withProps } from 'recompose' +import { FileSection, withFileSectionDrop } from 'pubsweet-component-faraday-ui' + +const Wrapped = compose( + withProps({ + files: [...], + listId: 'CoverLetter', + maxFiles: 3, + allowedFileExtensions: ['pdf'], + }), + withHandlers({ + changeList: () => (fromListId, toListId, fileId) => { + // do the actual change here + } + }), + withFileSectionDrop, +)(FileSection) + +export default Wrapped +``` + +## withNativeFileDrop + +HOC used to provide native file drop functionality to the `FileSection` component. It's purpose is to do something when dragging files from the computer's hard drive into the app. _This HOC allows only single items! Dragging multiple items into the wrapped component will only handle the first item!_ + +This HOC assumes the wrapped component has the following props: + +| Name | Type | Description | +| :-------------------- | :----------------------- | :--------------------------------------------- | +| files | `[{id: string, ...}]` | List of files passed to the wrapped component. | +| setError | `(error: string) => any` | Error setting callback. | +| allowedFileExtensions | `[string]` | Allowed file types. | +| maxFiles | `number` | Maximum number of files allowed. | +| onFileDrop | `(file: File) => any` | Callback fired when a valid file is dropped. | + +```js +import { compose, withHandler, withProps } from 'recompose' +import { FileSection, withNativeFileDrop } from 'pubsweet-component-faraday-ui' + +const Wrapped = compose( + withProps({ + files: [...], + listId: 'CoverLetter', + maxFiles: 3, + allowedFileExtensions: ['pdf'], + }), + withHandlers({ + onFileDrop: () => file => { + // do something with the dropped file + } + }), + withNativeFileDrop, +)(FileSection) + +export default Wrapped +``` + +# Utility functions + +## handleError + +Function that parses the server error. Calls the passed function with the parsed error. + +Has the following signature: +`(callbackFn: (parsedError) => any) => (e: Error) => any` + +```js +const customErrorLogger = parsedError => + console.error(`This is very handled: ${parsedError}`) + +// point free notation +anAsyncOperation().catch(handleError(customErrorLogger)) + +// can be used besides other function calls + +anAsyncOperation().catch(err => { + setFetching(false) + handleError(customErrorLogger)(err) +}) +``` diff --git a/packages/component-faraday-ui/src/helpers/helpers.md b/packages/component-faraday-ui/src/helpers/helpers.md deleted file mode 100644 index 15a652d3ec699c2b98c3f903793c34804a2272ae..0000000000000000000000000000000000000000 --- a/packages/component-faraday-ui/src/helpers/helpers.md +++ /dev/null @@ -1,297 +0,0 @@ -## Hindawi Helpers - -_Utility HOCs_ - -* [withCountries](#withcountries) -* [withFetching](#withfetching) -* [withFileDownload](#withfiledownload) -* [withFilePreview](#withfilepreview) -* [withPagination](#withpagination) -* [withRoles](#withroles) -* [withZipDownload](#withzipdownload) - -_HOCs used for files drag and drop_ - -* [withFileSectionDrop](#withfilesectiondrop) -* [withNativeFileDrop](#withnativefiledrop) - -_Utility functions_ - -* [handleError](#handleerror) - -# Utility HOCs - -## withCountries - -Injects `countries` and `countryLabel` as props. - -### withCountries props - -* `countries: [{value: string, label: string}]`: the list of countries -* `countryLabel: (code: string) => string`: get the name of the country with the specified code - -```js -import { Menu } from '@pubsweet/ui' -import { withCountries } from 'pubsweet-component-faraday-ui' - -const Wrapped = ({ countries, countryLabel }) => ( - <div> - <Menu options={countries} placeholder="Select a country" /> - - <span>Selected country: {countryLabel('RO')}</span> - </div> -) - -export default withCountries(Wrapped) -``` - -## withFetching - -Injects `isFetching`, `fetchingError`, `setFetching`, `toggleFetching`, `setError` and `clearError` as props. - -### withFetching props - -* `isFetching: bool`: value representing a pending async operation -* `fetchingError: string`: value representing the error -* `setFetching: (value: bool) => any`: function for setting the `isFetching` value -* `toggleFetching: () => any`: function that toggle the current value of `isFetching` -* `setError: (error: string) => any`: function that sets `fetchingError` -* `clearError: () => any`: function that resets `fetchingError` to it's original value - -```js -import { withFetching } from 'pubsweet-component-faraday-ui' - -const Wrapped = ({ isFetching, fetchingError, setFetching, toggleFetching }) => ( - <div> - {isFetching && <span>I am fetching</span>} - <span>{`The error: ${fetchingError}`</span> - <button onClick={() => setFetching(true)}>Set fetching true</button> - <button onClick={() => setFetching(false)}>Set fetching false</button> - <button onClick={toggleFetching}>Toggle fetching</button> - </div> -) - -export default withFetching(Wrapped) -``` - -## withFileDownload - -Injects `downloadFile` as a prop. - -### withFileDownload props - -* `downloadFile: (file: {id: string, name: string}) => any`: downloads the file specified as a parameter. The wrapped component should have the authentication token in a prop called `token` in order for this to work. - -```js -import { FileItem, withFileDownload } from 'pubsweet-component-faraday-ui' - -const file = { - id: 'myfile', - name: 'myfile.pdf', - size: 100231, -} - -const Wrapped = ({ downloadFile }) => ( - <div> - <FileItem item={file} onDownload={downloadfile} /> - </div> -) - -export default withFileDownload(Wrapped) -``` - -## withFilePreview - -Generate a securized file URL and preview it in a new tab. Injects `previewFile` as a prop. - -This HOC assumes the following props are present on the wrapped component: - -* `getSignedURL: (id: string) => Promise({signedURL: string})`: an async call that returns the securized S3 file url - -### withFilePreviewProps - -* `previewFile: (file: {id: string, ...}) => any`: opens the file preview in a new tab (only possible for PDF files and images) - -```javascript -import { withProps } from 'recompose' -import { FileItem, withFilePreview Wrapped} from 'pubsweet-component-faraday-ui' - -const file = { - id: 'myfile', - name: 'myfile.pdf', - size: 100231, -} - -const Wrapped = ({ previewFile }) => ( - <div> - <FileItem item={file} onPreview={previewFile} /> - </div> -) - -export default withFilePreview(Wrapped) -``` - -## withPagination - -Injects `page`, `itemsPerPage`, `toFirst`, `nextPage`, `toLast`, `prevPage`, `changeItemsPerPage`, `hasMore`, `maxItems` and `paginatedItems` as props. - -### withPagination props - -* `page: number`: the current page -* `itemsPerPage: number`: number of items to be shown per page -* `maxItems: number`: the total number of items -* `hasMore: bool`: if we're not at the last page yet -* `paginatedItems: [any]`: slice of the original items -* `toFirst: () => { page: number }`: go to the first page -* `toLast: () => {page: number}`: go to the last page -* `nextPage: () => {page: number}`: move to the next page -* `prevPage: () => {page: number}`: move to the previous page -* `changeItemsPerPage: e: HTMLInputEvent => {page: number, itemsPerPage: number}`: change the number of items per page - -```js -import { withPagination } from 'pubsweet-component-faraday-ui' - -const Wrapped = ({ page, nextPage, prevPage, paginatedItems, changeItemsPerPage }) => ( - <div> - <span>Page {page}</span> - <button onClick={prevPage}>Prev page</button> - <button onClick={nextPage}>Next page</button> - <input type="text" onChange={changeItemsPerPage} /> - <div> - { - paginatedItems.map(p => <span>{p}<span>) - } - </div> - </div> -) - -export default withPagination(Wrapped) -``` - -## withRoles - -Injects the `roles` array as a prop. The roles are parsed from the journal config files. - -### withRoles props - -* `roles: [{value: string, label: string}]`: an array of user roles - -```js -import { Menu } from '@pubsweet/ui' -import { withRoles } from 'pubsweet-component-faraday-ui' - -const Wrapped = ({ roles }) => <Menu options={roles} /> - -export default withRoles(Wrapped) -``` - -## withZipDownload - -Downloads all the files of a fragment as a zip archive. Injects the `downloadFiles` function as a prop. - -This HOCs assumes the following props are present on the wrapped component: - -* `token: string`: authentication token (used to authorize this request) -* `isReview: bool`: if the user is reviewer -* `fragmentId: string`: id of the fragment whose files we want to download -* `setFetching: (value: bool) => any`: a callback to set a fetching status -* `archiveName: string`: the name of the outputted archive file - -### withZipDownload props - -* `downloadFiles: () => any`: download all the fragment's file as a zip - -# Files drag and drop - -## withFileSectionDrop - -HOC used to provide drop functionality to the `FileSection` component. It's main purpose is to change a file from one list to another. This is usually done in a callback called `changeList` that should be provided to the wrapped component. - -This HOC assumes the wrapped component has the following props: - -* `files: [{id: string, ...}]`: the list of files passed to the wrapped component -* `setError: (error: string) => any`: error setting callback -* `listId: string`: the current list id -* `allowedFileExtensions: [string]`: the allowed files -* `maxFiles: number`: the maximum number of files allowed -* `changeList: (fromListId: string, toListId: string: fileId: string)`: callback called if all the conditions are met (allowed files, number of files, etc) - -```js -import { compose, withHandler, withProps } from 'recompose' -import { FileSection, withFileSectionDrop } from 'pubsweet-component-faraday-ui' - -const Wrapped = compose( - withProps({ - files: [...], - listId: 'CoverLetter', - maxFiles: 3, - allowedFileExtensions: ['pdf'], - }), - withHandlers({ - changeList: () => (fromListId, toListId, fileId) => { - // do the actual change here - } - }), - withFileSectionDrop, -)(FileSection) - -export default Wrapped -``` - -## withNativeFileDrop - -HOC used to provide native file drop functionality to the `FileSection` component. It's purpose is to do something when dragging files from the computer's hard drive into the app. _This HOC allows only single items! Dragging multiple items into the wrapped component will only handle the first item!_ - -This HOC assumes the wrapped component has the following props: - -* `files: [{id: string, ...}]`: the list of files passed to the wrapped component -* `setError: (error: string) => any`: error setting callback -* `allowedFileExtensions: [string]`: the allowed files -* `maxFiles: number`: the maximum number of files allowed -* `onFileDrop: (file: File)`: callback called when a valid file is dropped - -```js -import { compose, withHandler, withProps } from 'recompose' -import { FileSection, withNativeFileDrop } from 'pubsweet-component-faraday-ui' - -const Wrapped = compose( - withProps({ - files: [...], - listId: 'CoverLetter', - maxFiles: 3, - allowedFileExtensions: ['pdf'], - }), - withHandlers({ - onFileDrop: () => file => { - // do something with the dropped file - } - }), - withNativeFileDrop, -)(FileSection) - -export default Wrapped -``` - -# Utility functions - -## handleError - -Function that parses the server error. Calls the passed function with the parsed error. - -Has the following signature: -`(callbackFn: (parsedError) => any) => (e: Error) => any` - -```js -const customErrorLogger = parsedError => - console.error(`This is very handled: ${parsedError}`) - -// point free notation -anAsyncOperation().catch(handleError(customErrorLogger)) - -// can be used besides other function calls - -anAsyncOperation().catch(err => { - setFetching(false) - handleError(customErrorLogger)(err) -}) -``` diff --git a/packages/component-manuscript/src/handleRecommendation/README.md b/packages/component-manuscript/src/handleRecommendation/README.md new file mode 100644 index 0000000000000000000000000000000000000000..783844056d7c3ee2de1a003f86ceba5c3f74a315 --- /dev/null +++ b/packages/component-manuscript/src/handleRecommendation/README.md @@ -0,0 +1,45 @@ +## Hindawi Handling Recommendation HOC. + +Injects `createRecommendation` and `onEditorialRecommendation` handlers as props. + +### withHandleRecommendation props + +`recommendationHandler` namespace contains the following fields: +Name|Type|Description +---|---|--- +createRecommendation |`(reduxFormValues, modalProps) => any`|creates a recommendation for the manuscript +onEditorialRecommendation |`(reduxFormValues, modalProps) => any`|handles the recommendation for the manuscript + +_Note: The functions must be used withing a modal_ + +```javascript +const HERecommendationPanel = ({ createRecommendation }) => ( + <Modal> + <span>Recommend the manuscript for:</span> + <select> + <option>Approve</option> + <option>Reject</option> + <option>Minor revision</option> + <option>Major revision</option> + </select> + <button onClick={() => createRecommendation(reduxFormValues, { ...modalProps, setFetching })}> + Submit + </button> + </Modal> +) + +const EICDecisionPanel = ({ onEditorialRecommendation }) => ( + <Modal> + <span>Take decision to:</span> + <select> + <option>Approve</option> + <option>Reject</option> + <option>Minor revision</option> + <option>Major revision</option> + </select> + <button onClick={() => onEditorialRecommendation(reduxFormValues, { ...modalProps, setFetching })}> + Submit + </button> + </Modal> +) +``` diff --git a/packages/component-manuscript/src/inviteHandlingEditor/README.md b/packages/component-manuscript/src/inviteHandlingEditor/README.md new file mode 100644 index 0000000000000000000000000000000000000000..665c53eb15c3d8223e903d5249dfc10aaf688fe7 --- /dev/null +++ b/packages/component-manuscript/src/inviteHandlingEditor/README.md @@ -0,0 +1,46 @@ +## Hindawi Handling Editor Invite HOC. + +Injects `assignHE`, `revokeHE` and `onHEResponse` handlers as props. + +### withInviteHandlingEditor props + +`inviteHandlingEditor` namespace contains the following fields: +Name|Type|Description +---|---|--- +assignHE |`(email, modalProps) => any`|sends an invitation to the handling editor +revokeHE |`(invitationId, modalProps) => any`|revokes a sent invitation to the handling editor +onHEResponse |`(reduxFormValues, modalProps) => any`|handles the handling editor's response + +_Note: The functions must be used withing a modal_ + +```javascript +const EditorInChiefPanel = ({ assignHE, revokeHE }) => ( + <Modal> + <span>Handlin d'Editor</span> + <button onClick={() => assignHE(email, { ...modalProps, setFetching })}> + Resend Invitation + </button> + <button + onClick={() => revokeHE(invitationId, { ...modalProps, setFetching })} + > + Cancel Invitation + </button> + </Modal> +) + +const HandlingEditorPanel = ({ onHeResponse }) => ( + <Modal> + <span>Accept invitation?</span> + <button + onClick={() => onHeResponse(reduxFormValues, { ...modalProps, setFetching })} + > + Yes + </button> + <button + onClick={() => onHeResponse(reduxFormValues, { ...modalProps, setFetching })} + > + No + </button> + </Modal> +) +``` diff --git a/packages/component-manuscript/src/inviteHandlingEditor/withInviteHandlingEditor.md b/packages/component-manuscript/src/inviteHandlingEditor/withInviteHandlingEditor.md deleted file mode 100644 index 257c2b2a25142ef6f36953cc9d0f3067036aef95..0000000000000000000000000000000000000000 --- a/packages/component-manuscript/src/inviteHandlingEditor/withInviteHandlingEditor.md +++ /dev/null @@ -1,28 +0,0 @@ -## Hindawi Handling Editor Invite HOC. - -Injects `assignHE`, `revokeHE` and `onHEResponse` handlers as props. - -### withInviteHandlingEditor props - -* `inviteHandlingEditor: object`: namespace containing the following fields: - * `assignHE: function`: sends an invitation to the handling editor. - * `revokeHE: function`: revokes a sent invitation to the handling editor. - * `onHeResponse: function`: handles the handling editor's response. - -```javascript -const EditorInChiefPanel = ({ assignHE, revokeHE }) => ( - <Modal> - <span>Handlin d'Editor</span> - <button onClick={() => assignHE(email, {...modalProps, setFetching})}>Resend Invitation</button> - <button onClick={() => revokeHE(invitationId, {...modalProps, setFetching})}>Cancel Invitation</button> - </Modal> -) - -const HandlingEditorPanel = ({ onHeResponse }) => ( - <Modal> - <span>Accept invitation?</span> - <button onClick={() => onHeResponse(values, {...modalProps, setFetching})}>Yes</button> - <button onClick={() => onHeResponse(values, {...modalProps, setFetching})}>No</button> - </Modal> -) -``` diff --git a/packages/component-manuscript/src/inviteReviewer/withInviteReviewer.md b/packages/component-manuscript/src/inviteReviewer/README.md similarity index 62% rename from packages/component-manuscript/src/inviteReviewer/withInviteReviewer.md rename to packages/component-manuscript/src/inviteReviewer/README.md index e8d03b883b74aa3f5d3c5170cc594a13a2e9fa92..f8bae378764fa146d8a8b37169595783e080131a 100644 --- a/packages/component-manuscript/src/inviteReviewer/withInviteReviewer.md +++ b/packages/component-manuscript/src/inviteReviewer/README.md @@ -4,12 +4,16 @@ Injects `onInviteReviewer`, `onInvitePublonReviewer`, `onResendInviteReviewer`, ### withInviteReviewer props -* `inviteReviewer: object`: namespace containing the following fields: - * `onInviteReviewer: function`: sends an invitation to the reviewer. - * `onInvitePublonReviewer: function`: sends an invitation to a Publon reviewer. - * `onResendInviteReviewer: function`: resends an invitation to an already invited reviewer. - * `onRevokeInviteReviewer: function`: cancels an invitation to an invited reviewer. - * `onReviewerResponse: function`: handles the reviewer response to the invitation. +`inviteReviewer` namespace contains the following fields: +Name|Type|Description +---|---|--- +onInviteReviewer|`(reduxFormValues, modalProps) => any`|sends an invitation to the reviewer +onInvitePublonReviewer|`(reduxFormValues, modalProps) => any`|sends an invitation to a Publon reviewer +onResendInviteReviewer|`(email, modalProps) => any`|resends an invitation to an already invited reviewer +onRevokeInviteReviewer|`(invitationId, modalProps) => any`|cancels an invitation to an invited reviewer +onReviewerResponse|`(reduxFormValues, modalProps) => any`|handles the reviewer response to the invitation + +_Note: The functions must be used withing a modal_ ```javascript const InviteReviewer = ({ @@ -62,12 +66,16 @@ const Invitation = ({ onReviewerResponse }) => ( <Modal> <span>Accept invitation?</span> <button - onClick={() => onReviewerResponse(values, { ...modalProps, setFetching })} + onClick={() => + onReviewerResponse(reduxFormValues, { ...modalProps, setFetching }) + } > Yes </button> <button - onClick={() => onReviewerResponse(values, { ...modalProps, setFetching })} + onClick={() => + onReviewerResponse(reduxFormValues, { ...modalProps, setFetching }) + } > No </button>