1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 10:25:08 +01:00

Small change to PR piece registration

Ignore `success` return of request, as requests will error if this is
returned false.
This commit is contained in:
Brett Sun 2015-12-14 14:34:13 +01:00
parent 9342262f5c
commit e24c9c9c74

View File

@ -75,7 +75,7 @@ const PRRegisterPieceForm = React.createClass({
const additionalDataFormData = additionalDataForm.getFormData(); const additionalDataFormData = additionalDataForm.getFormData();
// composing data for piece registration // composing data for piece registration
let registerPieceFormData = registerPieceForm.getFormData(); const registerPieceFormData = registerPieceForm.getFormData();
registerPieceFormData.digital_work_key = digitalWorkKey.state.value; registerPieceFormData.digital_work_key = digitalWorkKey.state.value;
registerPieceFormData.thumbnail_file = thumbnailKey.state.value; registerPieceFormData.thumbnail_file = thumbnailKey.state.value;
registerPieceFormData.terms = true; registerPieceFormData.terms = true;
@ -83,33 +83,33 @@ const PRRegisterPieceForm = React.createClass({
// submitting the piece // submitting the piece
requests requests
.post(ApiUrls.pieces_list, { body: registerPieceFormData }) .post(ApiUrls.pieces_list, { body: registerPieceFormData })
.then(({ success, piece, notification }) => { .then(({ piece, notification }) => {
if(success) { this.setState({piece}, () => {
this.setState({ supportingMaterials.refs.input.createBlobRoutine();
piece proofOfPayment.refs.input.createBlobRoutine();
}, () => { });
supportingMaterials.refs.input.createBlobRoutine();
proofOfPayment.refs.input.createBlobRoutine();
});
setCookie(currentUser.email, piece.id); setCookie(currentUser.email, piece.id);
return requests.post(ApiUrls.piece_extradata, { return requests
.post(ApiUrls.piece_extradata, {
body: { body: {
extradata: additionalDataFormData, extradata: additionalDataFormData,
piece_id: piece.id piece_id: piece.id
}, },
piece_id: piece.id piece_id: piece.id
})
.then(() => {
const notificationMessage = new GlobalNotificationModel(notification || getLangText('You have successfully submitted "%s" to Portfolio Review 2015', piece.title), 'success', 5000);
GlobalNotificationActions.appendGlobalNotification(notificationMessage);
}); });
} else {
const notificationMessage = new GlobalNotificationModel(notification, 'danger', 5000);
GlobalNotificationActions.appendGlobalNotification(notificationMessage);
}
}) })
.then(() => this.history.pushState(null, `/pieces/${this.state.piece.id}`)) .then(() => this.history.pushState(null, `/pieces/${this.state.piece.id}`))
.catch(() => { .catch((err) => {
const notificationMessage = new GlobalNotificationModel(getLangText("Oops! We weren't able to send your submission. Contact: support@ascribe.io"), 'danger', 5000); const notificationMessage = new GlobalNotificationModel(getLangText("Oops! We weren't able to send your submission. Contact: support@ascribe.io"), 'danger', 5000);
GlobalNotificationActions.appendGlobalNotification(notificationMessage); GlobalNotificationActions.appendGlobalNotification(notificationMessage);
console.logGlobal(new Error('Portfolio Review piece registration failed'), err);
}); });
}, },
@ -167,7 +167,7 @@ const PRRegisterPieceForm = React.createClass({
} else { } else {
return ( return (
<button <button
type="submit" type="button"
className="btn btn-default btn-wide" className="btn btn-default btn-wide"
disabled={!(digitalWorkKeyReady && thumbnailKeyReady && proofOfPaymentReady && supportingMaterialsReady)} disabled={!(digitalWorkKeyReady && thumbnailKeyReady && proofOfPaymentReady && supportingMaterialsReady)}
onClick={this.submit}> onClick={this.submit}>