From be7fa0c6ebf08f43ededab93651da7ca438bab62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 10 Nov 2015 10:15:38 +0100 Subject: [PATCH] Add conditional redirect after successful registration --- .../components/pr_forms/pr_register_piece_form.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/js/components/whitelabel/prize/portfolioreview/components/pr_forms/pr_register_piece_form.js b/js/components/whitelabel/prize/portfolioreview/components/pr_forms/pr_register_piece_form.js index e8063f8b..c07b0600 100644 --- a/js/components/whitelabel/prize/portfolioreview/components/pr_forms/pr_register_piece_form.js +++ b/js/components/whitelabel/prize/portfolioreview/components/pr_forms/pr_register_piece_form.js @@ -1,6 +1,7 @@ 'use strict'; import React from 'react'; +import { History } from 'react-router'; import Form from '../../../../../ascribe_forms/form'; import Property from '../../../../../ascribe_forms/property'; @@ -29,6 +30,8 @@ const PRRegisterPieceForm = React.createClass({ currentUser: object }, + mixins: [History], + getInitialState(){ return { isUploadReady: false, @@ -47,7 +50,8 @@ const PRRegisterPieceForm = React.createClass({ digitalWorkForm, proofOfPaymentForm, supportingMaterialsForm, - additionalDataForm } = this.refs; + additionalDataForm, + thumbnailForm } = this.refs; const additionalDataFormData = additionalDataForm.getFormData(); // composing data for piece registration @@ -65,10 +69,10 @@ const PRRegisterPieceForm = React.createClass({ }, () => { supportingMaterialsForm.createBlobRoutine(); proofOfPaymentForm.createBlobRoutine(); - //thumbnailForm.createBlobRoutine(); + thumbnailForm.createBlobRoutine(); }); - setCookie(currentUser.email, piece.id); + //setCookie(currentUser.email, piece.id); return requests.post(ApiUrls.piece_extradata, { body: { @@ -82,6 +86,7 @@ const PRRegisterPieceForm = React.createClass({ GlobalNotificationActions.appendGlobalNotification(notificationMessage); } }) + .then(() => this.history.pushState(null, `/pieces/${this.state.piece.id}`)) .catch((err) => { console.log(err); }); @@ -99,7 +104,7 @@ const PRRegisterPieceForm = React.createClass({ }; } else if(fileClass === 'thumbnail') { return { - url: ApiUrls.blob_thumbnail, + url: ApiUrls.blob_thumbnails, pieceId: piece.id }; }