diff --git a/frontend/src/Components/Form/BookshelfInput.js b/frontend/src/Components/Form/BookshelfInput.js index a93549ee8..c5a7c6ef7 100644 --- a/frontend/src/Components/Form/BookshelfInput.js +++ b/frontend/src/Components/Form/BookshelfInput.js @@ -182,7 +182,8 @@ BookshelfInput.propTypes = { BookshelfInput.defaultProps = { className: styles.bookshelfInputWrapper, - inputClassName: styles.input + inputClassName: styles.input, + isPopulated: false }; export default BookshelfInput; diff --git a/frontend/src/Components/Form/BookshelfInputConnector.js b/frontend/src/Components/Form/BookshelfInputConnector.js index deaf73d98..27c5ad5a0 100644 --- a/frontend/src/Components/Form/BookshelfInputConnector.js +++ b/frontend/src/Components/Form/BookshelfInputConnector.js @@ -3,22 +3,22 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { clearOptions, fetchOptions } from 'Store/Actions/providerOptionActions'; +import { clearOptions, defaultState, fetchOptions } from 'Store/Actions/providerOptionActions'; import BookshelfInput from './BookshelfInput'; function createMapStateToProps() { return createSelector( - (state) => state.providerOptions, + (state) => state.providerOptions.bookshelves || defaultState, (state, props) => props.name, - (state, name) => { + (bookshelves, name) => { const { items, ...otherState - } = state; + } = bookshelves; return ({ helptext: items.helptext && items.helptext[name] ? items.helptext[name] : '', - user: items.user ? items.user : '', - items: items.shelves ? items.shelves : [], + user: items && items.user ? items.user : '', + items: items && items.shelves ? items.shelves : [], ...otherState }); } @@ -50,7 +50,7 @@ class BookshelfInputConnector extends Component { } componentWillUnmount = () => { - this.props.dispatchClearOptions(); + this.props.dispatchClearOptions({ section: 'bookshelves' }); } // @@ -65,6 +65,7 @@ class BookshelfInputConnector extends Component { } = this.props; dispatchFetchOptions({ + section: 'bookshelves', action: 'getBookshelves', queryParams: { name }, provider,