From 7136f2ce6cc1d976c5a49e40b0a07a1cb3ab7f36 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Thu, 14 Jan 2016 13:20:45 +0100 Subject: [PATCH] Add getInitialState and source pattern for PieceStore --- js/actions/piece_actions.js | 19 +-- .../ascribe_detail/edition_container.js | 1 + js/components/ascribe_detail/piece.js | 2 +- .../ascribe_detail/piece_container.js | 60 ++++----- .../ascribe_detail/prize_piece_container.js | 116 +++++++++--------- .../cyland_detail/cyland_piece_container.js | 34 ++--- .../cyland/cyland_register_piece.js | 48 +++----- .../ikonotv_detail/ikonotv_piece_container.js | 40 +++--- .../ikonotv/ikonotv_register_piece.js | 67 +++++----- .../market_buttons/market_submit_button.js | 2 +- .../market_additional_data_form.js | 6 +- js/fetchers/piece_fetcher.js | 15 --- js/sources/piece_source.js | 19 +++ js/stores/piece_store.js | 55 +++++++-- 14 files changed, 252 insertions(+), 232 deletions(-) delete mode 100644 js/fetchers/piece_fetcher.js create mode 100644 js/sources/piece_source.js diff --git a/js/actions/piece_actions.js b/js/actions/piece_actions.js index 9002e8c5..7ad3ae29 100644 --- a/js/actions/piece_actions.js +++ b/js/actions/piece_actions.js @@ -1,28 +1,19 @@ 'use strict'; import { alt } from '../alt'; -import PieceFetcher from '../fetchers/piece_fetcher'; class PieceActions { constructor() { this.generateActions( + 'fetchPiece', + 'successFetchPiece', + 'errorPiece', + 'flushPiece', 'updatePiece', - 'updateProperty', - 'pieceFailed' + 'updateProperty' ); } - - fetchOne(pieceId) { - PieceFetcher.fetchOne(pieceId) - .then((res) => { - this.actions.updatePiece(res.piece); - }) - .catch((err) => { - console.logGlobal(err); - this.actions.pieceFailed(err.json); - }); - } } export default alt.createActions(PieceActions); diff --git a/js/components/ascribe_detail/edition_container.js b/js/components/ascribe_detail/edition_container.js index 17ba27d6..bd13e118 100644 --- a/js/components/ascribe_detail/edition_container.js +++ b/js/components/ascribe_detail/edition_container.js @@ -52,6 +52,7 @@ let EditionContainer = React.createClass({ // button to update the URL parameter (and therefore to switch pieces) componentWillReceiveProps(nextProps) { if(this.props.params.editionId !== nextProps.params.editionId) { + EditionActions.flushEdition(); this.loadEdition(nextProps.params.editionId); } }, diff --git a/js/components/ascribe_detail/piece.js b/js/components/ascribe_detail/piece.js index d779b716..e4ff4ea7 100644 --- a/js/components/ascribe_detail/piece.js +++ b/js/components/ascribe_detail/piece.js @@ -28,7 +28,7 @@ let Piece = React.createClass({ updateObject() { - return PieceActions.fetchOne(this.props.piece.id); + return PieceActions.fetchPiece(this.props.piece.id); }, render() { diff --git a/js/components/ascribe_detail/piece_container.js b/js/components/ascribe_detail/piece_container.js index 6c3b82a6..e41b0e2e 100644 --- a/js/components/ascribe_detail/piece_container.js +++ b/js/components/ascribe_detail/piece_container.js @@ -69,7 +69,7 @@ let PieceContainer = React.createClass({ return mergeOptions( UserStore.getState(), PieceListStore.getState(), - PieceStore.getState(), + PieceStore.getInitialState(), { showCreateEditionsDialog: false } @@ -81,19 +81,24 @@ let PieceContainer = React.createClass({ PieceListStore.listen(this.onChange); PieceStore.listen(this.onChange); - // Every time we enter the piece detail page, just reset the piece - // store as it will otherwise display wrong/old data once the user loads - // the piece detail a second time - PieceActions.updatePiece({}); - this.loadPiece(); UserActions.fetchCurrentUser(); }, - componentDidUpdate() { - const { pieceError } = this.state; + // This is done to update the container when the user clicks on the prev or next + // button to update the URL parameter (and therefore to switch pieces) or + // when the user clicks on a notification while being in another piece view + componentWillReceiveProps(nextProps) { + if (this.props.params.pieceId !== nextProps.params.pieceId) { + PieceActions.flushPiece(); + this.loadPiece(nextProps.params.pieceId); + } + }, - if (pieceError && pieceError.status === 404) { + componentDidUpdate() { + const { pieceMeta: { err: pieceErr } } = this.state; + + if (pieceErr && pieceErr.status === 404) { this.throws(new ResourceNotFoundError(getLangText("Oops, the piece you're looking for doesn't exist."))); } }, @@ -116,8 +121,7 @@ let PieceContainer = React.createClass({ ALSO, WE ENABLED THE LOAN BUTTON FOR IKONOTV TO LET THEM LOAN ON A PIECE LEVEL */ - if(state && state.piece && state.piece.acl && typeof state.piece.acl.acl_loan !== 'undefined') { - + if (state && state.piece && state.piece.acl && typeof state.piece.acl.acl_loan !== 'undefined') { let pieceState = mergeOptions({}, state.piece); pieceState.acl.acl_loan = false; this.setState({ @@ -129,11 +133,10 @@ let PieceContainer = React.createClass({ } }, - loadPiece() { - PieceActions.fetchOne(this.props.params.pieceId); + loadPiece(pieceId = this.props.params.pieceId) { + PieceActions.fetchPiece(pieceId); }, - toggleCreateEditionsDialog() { this.setState({ showCreateEditionsDialog: !this.state.showCreateEditionsDialog @@ -141,7 +144,7 @@ let PieceContainer = React.createClass({ }, handleEditionCreationSuccess() { - PieceActions.updateProperty({key: 'num_editions', value: 0}); + PieceActions.updateProperty({ key: 'num_editions', value: 0 }); PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc, this.state.filterBy); this.toggleCreateEditionsDialog(); @@ -156,29 +159,28 @@ let PieceContainer = React.createClass({ EditionListActions.closeAllEditionLists(); EditionListActions.clearAllEditionSelections(); - let notification = new GlobalNotificationModel(response.notification, 'success'); + const notification = new GlobalNotificationModel(response.notification, 'success'); GlobalNotificationActions.appendGlobalNotification(notification); this.history.push('/collection'); }, getCreateEditionsDialog() { - if(this.state.piece.num_editions < 1 && this.state.showCreateEditionsDialog) { + if (this.state.piece.num_editions < 1 && this.state.showCreateEditionsDialog) { return (
-
+
); } else { - return (
); + return (
); } }, handlePollingSuccess(pieceId, numEditions) { - // we need to refresh the num_editions property of the actual piece we're looking at PieceActions.updateProperty({ key: 'num_editions', @@ -192,24 +194,24 @@ let PieceContainer = React.createClass({ PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc, this.state.filterBy); - let notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000); + const notification = new GlobalNotificationModel('Editions successfully created', 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); }, getId() { - return {'id': this.state.piece.id}; + return { 'id': this.state.piece.id }; }, getActions() { const { piece, currentUser } = this.state; - if (piece && piece.notifications && piece.notifications.length > 0) { + if (piece.notifications && piece.notifications.length > 0) { return ( ); + notifications={piece.notifications} />); } else { return ( + piece={piece} /> + aclObject={piece.acl} /> @@ -252,7 +254,7 @@ let PieceContainer = React.createClass({ const { furtherDetailsType: FurtherDetailsType } = this.props; const { currentUser, piece } = this.state; - if (piece && piece.id) { + if (piece.id) { setDocumentTitle([piece.artist_name, piece.title].join(', ')); return ( @@ -296,7 +298,7 @@ let PieceContainer = React.createClass({ editable={true} successMessage={getLangText('Private note saved')} url={ApiUrls.note_private_piece} - currentUser={currentUser}/> + currentUser={currentUser} /> + currentUser={currentUser} /> 0) { + if (piece.notifications && piece.notifications.length > 0) { return ( ); + notifications={piece.notifications} />); } }, loadPiece(pieceId = this.props.params.pieceId) { - PieceActions.fetchOne(pieceId); + PieceActions.fetchPiece(pieceId); }, render() { const { selectedPrizeActionButton } = this.props; const { currentUser, piece } = this.state; - if (piece && piece.id) { + if (piece.id) { /* This really needs a refactor! @@ -138,7 +133,7 @@ let PrizePieceContainer = React.createClass({ // Only show the artist name if you are the participant or if you are a judge and the piece is shortlisted let artistName; if ((currentUser.is_jury && !currentUser.is_judge) || (currentUser.is_judge && !piece.selected )) { - artistName = ); - } else if (this.props.currentUser && this.props.currentUser.is_jury) { + } else if (this.props.currentUser.is_jury) { // Jury can set rating and note return ( {return {'piece_id': this.props.piece.id}; }} + id={() => { return { 'piece_id': this.props.piece.id }; }} label={getLangText('Jury note')} - defaultValue={this.props.piece && this.props.piece.note_from_user ? this.props.piece.note_from_user.note : null} + defaultValue={this.props.piece.note_from_user || null} placeholder={getLangText('Enter your comments ...')} editable={true} successMessage={getLangText('Jury note saved')} url={ApiUrls.notes} - currentUser={this.props.currentUser}/> + currentUser={this.props.currentUser} /> ); } else { return null; @@ -432,33 +430,34 @@ let PrizePieceDetails = React.createClass({ render() { const { piece } = this.props; - if (piece && - piece.prize && - piece.prize.name && - Object.keys(piece.extra_data).length !== 0) { + if (piece.prize && piece.prize.name && Object.keys(piece.extra_data).length) { return ( -
- {Object.keys(piece.extra_data).sort().map((data) => { - // Remove leading number (for sorting), if any, and underscores with spaces - let label = data.replace(/^\d-/, '').replace(/_/g, ' '); - const value = piece.extra_data[data] || 'N/A'; + + {Object + .keys(piece.extra_data) + .sort() + .map((data) => { + // Remove leading number (for sorting), if any, and underscores with spaces + const label = data.replace(/^\d-/, '').replace(/_/g, ' '); + const value = piece.extra_data[data] || 'N/A'; - return ( - - - - ); - })} + return ( + + + + ); + }) + } {}} setIsUploadReady={() => {}} @@ -471,8 +470,9 @@ let PrizePieceDetails = React.createClass({
); + } else { + return null; } - return null; } }); diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js b/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js index 4a857e92..7f588df0 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_detail/cyland_piece_container.js @@ -40,7 +40,7 @@ let CylandPieceContainer = React.createClass({ getInitialState() { return mergeOptions( - PieceStore.getState(), + PieceStore.getInitialState(), UserStore.getState(), PieceListStore.getState() ); @@ -51,14 +51,17 @@ let CylandPieceContainer = React.createClass({ UserStore.listen(this.onChange); PieceListStore.listen(this.onChange); - // Every time we enter the piece detail page, just reset the piece - // store as it will otherwise display wrong/old data once the user loads - // the piece detail a second time - PieceActions.updatePiece({}); - this.loadPiece(); }, + // We need this for when the user clicks on a notification while being in another piece view + componentWillReceiveProps(nextProps) { + if (this.props.params.pieceId !== nextProps.params.pieceId) { + PieceActions.flushPiece(); + this.loadPiece(); + } + }, + componentWillUnmount() { PieceStore.unlisten(this.onChange); UserStore.unlisten(this.onChange); @@ -70,7 +73,7 @@ let CylandPieceContainer = React.createClass({ }, loadPiece() { - PieceActions.fetchOne(this.props.params.pieceId); + PieceActions.fetchPiece(this.props.params.pieceId); }, handleDeleteSuccess(response) { @@ -82,19 +85,21 @@ let CylandPieceContainer = React.createClass({ EditionListActions.closeAllEditionLists(); EditionListActions.clearAllEditionSelections(); - let notification = new GlobalNotificationModel(response.notification, 'success'); + const notification = new GlobalNotificationModel(response.notification, 'success'); GlobalNotificationActions.appendGlobalNotification(notification); this.history.push('/collection'); }, render() { - if(this.state.piece && this.state.piece.id) { - setDocumentTitle([this.state.piece.artist_name, this.state.piece.title].join(', ')); + const { piece } = this.state; + + if (piece.id) { + setDocumentTitle([piece.artist_name, piece.title].join(', ')); return ( ); - } - else { + } else { return (
diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js index 3f5f0116..2c1e3f9c 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js @@ -52,7 +52,7 @@ let CylandRegisterPiece = React.createClass({ return mergeOptions( UserStore.getState(), PieceListStore.getState(), - PieceStore.getState(), + PieceStore.getInitialState(), WhitelabelStore.getState(), { step: 0 @@ -67,7 +67,7 @@ let CylandRegisterPiece = React.createClass({ UserActions.fetchCurrentUser(); WhitelabelActions.fetchWhitelabel(); - let queryParams = this.props.location.query; + const queryParams = this.props.location.query; // Since every step of this register process is atomic, // we may need to enter the process at step 1 or 2. @@ -76,8 +76,8 @@ let CylandRegisterPiece = React.createClass({ // // We're using 'in' here as we want to know if 'piece_id' is present in the url, // we don't care about the value. - if(queryParams && 'piece_id' in queryParams) { - PieceActions.fetchOne(queryParams.piece_id); + if ('piece_id' in queryParams) { + PieceActions.fetchPiece(queryParams.piece_id); } }, @@ -92,53 +92,44 @@ let CylandRegisterPiece = React.createClass({ this.setState(state); }, - handleRegisterSuccess(response){ - + handleRegisterSuccess(response) { this.refreshPieceList(); - // also start loading the piece for the next step - if(response && response.piece) { - PieceActions.updatePiece({}); + // Also load the newly registered piece for the next step + if (response && response.piece) { PieceActions.updatePiece(response.piece); } - this.incrementStep(); - - this.refs.slidesContainer.nextSlide({ piece_id: response.piece.id }); + this.nextSlide({ piece_id: response.piece.id }); }, handleAdditionalDataSuccess() { - // We need to refetch the piece again after submitting the additional data - // since we want it's otherData to be displayed when the user choses to click + // since we want its otherData to be displayed when the user choses to click // on the browsers back button. - PieceActions.fetchOne(this.state.piece.id); + PieceActions.fetchPiece(this.state.piece.id); this.refreshPieceList(); - this.incrementStep(); - - this.refs.slidesContainer.nextSlide(); + this.nextSlide(); }, handleLoanSuccess(response) { - let notification = new GlobalNotificationModel(response.notification, 'success', 10000); + const notification = new GlobalNotificationModel(response.notification, 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); this.refreshPieceList(); - PieceActions.fetchOne(this.state.piece.id); - this.history.push(`/pieces/${this.state.piece.id}`); }, - // We need to increase the step to lock the forms that are already filled out - incrementStep() { - // also increase step - let newStep = this.state.step + 1; + nextSlide(queryParams) { + // We need to increase the step to lock the forms that are already filled out this.setState({ - step: newStep + step: this.state.step + 1 }); + + this.refs.slidesContainer.nextSlide(queryParams); }, refreshPieceList() { @@ -157,8 +148,7 @@ let CylandRegisterPiece = React.createClass({ const { currentUser, piece, step, whitelabel } = this.state; const today = new Moment(); - const datetimeWhenWeAllWillBeFlyingCoolHoverboardsAndDinosaursWillLiveAgain = new Moment(); - datetimeWhenWeAllWillBeFlyingCoolHoverboardsAndDinosaursWillLiveAgain.add(1000, 'years'); + const datetimeWhenWeAllWillBeFlyingCoolHoverboardsAndDinosaursWillLiveAgain = new Moment().add(1000, 'years'); const loanHeading = getLangText('Loan to Cyland archive'); const loanButtons = ( @@ -201,7 +191,7 @@ let CylandRegisterPiece = React.createClass({ submitMessage={getLangText('Submit')} isFineUploaderActive={true} handleSuccess={this.handleRegisterSuccess} - location={location}/> + location={location} />
diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js index c9b5ca83..c7c35c7c 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_detail/ikonotv_piece_container.js @@ -41,7 +41,7 @@ let IkonotvPieceContainer = React.createClass({ getInitialState() { return mergeOptions( - PieceStore.getState(), + PieceStore.getInitialState(), UserStore.getState(), PieceListStore.getState() ); @@ -52,19 +52,14 @@ let IkonotvPieceContainer = React.createClass({ UserStore.listen(this.onChange); PieceListStore.listen(this.onChange); - // Every time we enter the piece detail page, just reset the piece - // store as it will otherwise display wrong/old data once the user loads - // the piece detail a second time - PieceActions.updatePiece({}); - this.loadPiece(); }, - // We need this for when the user clicks on a notification while being in another piece view + // We need this for when the user clicks on a notification while being in another piece view componentWillReceiveProps(nextProps) { - if(this.props.params.pieceId !== nextProps.params.pieceId) { - PieceActions.updatePiece({}); - PieceActions.fetchOne(nextProps.params.pieceId); + if (this.props.params.pieceId !== nextProps.params.pieceId) { + PieceActions.flushPiece(); + this.loadPiece(); } }, @@ -79,7 +74,7 @@ let IkonotvPieceContainer = React.createClass({ }, loadPiece() { - PieceActions.fetchOne(this.props.params.pieceId); + PieceActions.fetchPiece(this.props.params.pieceId); }, handleDeleteSuccess(response) { @@ -91,13 +86,15 @@ let IkonotvPieceContainer = React.createClass({ EditionListActions.closeAllEditionLists(); EditionListActions.clearAllEditionSelections(); - let notification = new GlobalNotificationModel(response.notification, 'success'); + const notification = new GlobalNotificationModel(response.notification, 'success'); GlobalNotificationActions.appendGlobalNotification(notification); this.history.push('/collection'); }, render() { + const { piece } = this.state; + let furtherDetails = ( ); - if(this.state.piece.extra_data && Object.keys(this.state.piece.extra_data).length > 0 && this.state.piece.acl) { + if (piece.extra_data && Object.keys(piece.extra_data).length && piece.acl) { furtherDetails = ( + disabled={!piece.acl.acl_edit} /> + disabled={!piece.acl.acl_edit} /> ); } - if(this.state.piece && this.state.piece.id) { - setDocumentTitle([this.state.piece.artist_name, this.state.piece.title].join(', ')); + if (piece.id) { + setDocumentTitle([piece.artist_name, piece.title].join(', ')); return ( ); - } - else { + } else { return (
diff --git a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js index 508f1d68..544b738a 100644 --- a/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js +++ b/js/components/whitelabel/wallet/components/ikonotv/ikonotv_register_piece.js @@ -49,7 +49,7 @@ let IkonotvRegisterPiece = React.createClass({ return mergeOptions( UserStore.getState(), PieceListStore.getState(), - PieceStore.getState(), + PieceStore.getInitialState(), WhitelabelStore.getState(), { step: 0, @@ -65,11 +65,7 @@ let IkonotvRegisterPiece = React.createClass({ UserActions.fetchCurrentUser(); WhitelabelActions.fetchWhitelabel(); - // Before we load the new piece, we reset the piece store to delete old data that we do - // not want to display to the user. - PieceActions.updatePiece({}); - - let queryParams = this.props.location.query; + const queryParams = this.props.location.query; // Since every step of this register process is atomic, // we may need to enter the process at step 1 or 2. @@ -78,8 +74,8 @@ let IkonotvRegisterPiece = React.createClass({ // // We're using 'in' here as we want to know if 'piece_id' is present in the url, // we don't care about the value. - if (queryParams && 'piece_id' in queryParams) { - PieceActions.fetchOne(queryParams.piece_id); + if ('piece_id' in queryParams) { + PieceActions.fetchPiece(queryParams.piece_id); } }, @@ -95,55 +91,50 @@ let IkonotvRegisterPiece = React.createClass({ }, - handleRegisterSuccess(response){ + handleRegisterSuccess(response) { this.refreshPieceList(); - // also start loading the piece for the next step - if(response && response.piece) { + // Also load the newly registered piece for the next step + if (response && response.piece) { PieceActions.updatePiece(response.piece); } + if (!this.canSubmit()) { this.history.push('/collection'); - } - else { - this.incrementStep(); - this.refs.slidesContainer.nextSlide(); + } else { + this.nextSlide({ piece_id: response.piece.id }); } }, handleAdditionalDataSuccess() { - // We need to refetch the piece again after submitting the additional data // since we want it's otherData to be displayed when the user choses to click // on the browsers back button. - PieceActions.fetchOne(this.state.piece.id); + PieceActions.fetchPiece(this.state.piece.id); this.refreshPieceList(); - this.incrementStep(); - - this.refs.slidesContainer.nextSlide(); + this.nextSlide(); }, handleLoanSuccess(response) { this.setState({ pageExitWarning: null }); - let notification = new GlobalNotificationModel(response.notification, 'success', 10000); + const notification = new GlobalNotificationModel(response.notification, 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); this.refreshPieceList(); - PieceActions.fetchOne(this.state.piece.id); this.history.push(`/pieces/${this.state.piece.id}`); }, - // We need to increase the step to lock the forms that are already filled out - incrementStep() { - // also increase step - let newStep = this.state.step + 1; + nextSlide(queryParams) { + // We need to increase the step to lock the forms that are already filled out this.setState({ - step: newStep + step: this.state.step + 1 }); + + this.refs.slidesContainer.nextSlide(queryParams); }, refreshPieceList() { @@ -160,7 +151,7 @@ let IkonotvRegisterPiece = React.createClass({ canSubmit() { let currentUser = this.state.currentUser; let whitelabel = this.state.whitelabel; - return currentUser && currentUser.acl && currentUser.acl.acl_wallet_submit && whitelabel && whitelabel.user; + return currentUser.acl && currentUser.acl.acl_wallet_submit && whitelabel.user; }, getSlideArtistDetails() { @@ -171,13 +162,14 @@ let IkonotvRegisterPiece = React.createClass({ + piece={this.state.piece} />
); + } else { + return null; } - return null; }, getSlideArtworkDetails() { @@ -188,21 +180,21 @@ let IkonotvRegisterPiece = React.createClass({ + piece={this.state.piece} /> ); + } else { + return null; } - return null; }, getSlideLoan() { if (this.canSubmit()) { const { piece, whitelabel } = this.state; - let today = new Moment(); - let endDate = new Moment(); - endDate.add(2, 'years'); + const today = new Moment(); + const endDate = new Moment().add(2, 'years'); return (
@@ -225,8 +217,9 @@ let IkonotvRegisterPiece = React.createClass({
); + } else { + return null; } - return null; }, render() { @@ -252,7 +245,7 @@ let IkonotvRegisterPiece = React.createClass({ submitMessage={getLangText('Register')} isFineUploaderActive={true} handleSuccess={this.handleRegisterSuccess} - location={this.props.location}/> + location={this.props.location} /> diff --git a/js/components/whitelabel/wallet/components/market/market_buttons/market_submit_button.js b/js/components/whitelabel/wallet/components/market/market_buttons/market_submit_button.js index d8ef4c41..2d31b13c 100644 --- a/js/components/whitelabel/wallet/components/market/market_buttons/market_submit_button.js +++ b/js/components/whitelabel/wallet/components/market/market_buttons/market_submit_button.js @@ -84,7 +84,7 @@ let MarketSubmitButton = React.createClass({ handleAdditionalDataSuccess(pieceId) { // Fetch newly updated piece to update the views - PieceActions.fetchOne(pieceId); + PieceActions.fetchPiece(pieceId); this.refs.consignModal.show(); }, diff --git a/js/components/whitelabel/wallet/components/market/market_forms/market_additional_data_form.js b/js/components/whitelabel/wallet/components/market/market_forms/market_additional_data_form.js index d136c9cf..6982e539 100644 --- a/js/components/whitelabel/wallet/components/market/market_forms/market_additional_data_form.js +++ b/js/components/whitelabel/wallet/components/market/market_forms/market_additional_data_form.js @@ -63,7 +63,7 @@ let MarketAdditionalDataForm = React.createClass({ PieceStore.listen(this.onChange); if (this.props.pieceId) { - PieceActions.fetchOne(this.props.pieceId); + PieceActions.fetchPiece(this.props.pieceId); } }, @@ -115,7 +115,7 @@ let MarketAdditionalDataForm = React.createClass({ this.props.handleSuccess(); } - let notification = new GlobalNotificationModel(getLangText('Further details successfully updated'), 'success', 10000); + const notification = new GlobalNotificationModel(getLangText('Further details successfully updated'), 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); }, @@ -159,7 +159,7 @@ let MarketAdditionalDataForm = React.createClass({ ) : null; } - if (piece && piece.id) { + if (piece.id) { return (