mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Add consign error to market white labels
Can you beliebe? Magical 100th commit.
This commit is contained in:
parent
c1959033c0
commit
cb972eb448
@ -3,6 +3,8 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import MarketConsignError from '../market_consign_error';
|
||||
|
||||
import MarketAdditionalDataForm from '../market_forms/market_additional_data_form';
|
||||
|
||||
import AclFormFactory from '../../../../../ascribe_forms/acl_form_factory';
|
||||
@ -12,6 +14,7 @@ import ModalWrapper from '../../../../../ascribe_modal/modal_wrapper';
|
||||
|
||||
import AclProxy from '../../../../../acl_proxy';
|
||||
|
||||
import EditionListActions from '../../../../../../actions/edition_list_actions';
|
||||
import PieceActions from '../../../../../../actions/piece_actions';
|
||||
import WhitelabelActions from '../../../../../../actions/whitelabel_actions';
|
||||
import WhitelabelStore from '../../../../../../stores/whitelabel_store';
|
||||
@ -89,6 +92,11 @@ let MarketSubmitButton = React.createClass({
|
||||
this.refs.consignModal.show();
|
||||
},
|
||||
|
||||
handleConsignError() {
|
||||
// Unselect failed editions
|
||||
EditionListActions.clearAllEditionSelections();
|
||||
},
|
||||
|
||||
render() {
|
||||
const { availableAcls, currentUser, className, editions, handleSuccess } = this.props;
|
||||
const { whitelabel: { name: whitelabelName = 'Market', user: whitelabelAdminEmail } } = this.state;
|
||||
@ -120,27 +128,45 @@ let MarketSubmitButton = React.createClass({
|
||||
);
|
||||
|
||||
if (solePieceId && !canSubmit) {
|
||||
return (
|
||||
<AclProxy
|
||||
aclObject={availableAcls}
|
||||
aclName='acl_consign'>
|
||||
if (availableAcls.acl_edit) {
|
||||
return (
|
||||
<AclProxy
|
||||
aclObject={availableAcls}
|
||||
aclName='acl_consign'>
|
||||
<ModalWrapper
|
||||
trigger={triggerButton}
|
||||
handleSuccess={this.handleAdditionalDataSuccess.bind(this, solePieceId)}
|
||||
title={getLangText('Add additional information')}>
|
||||
<MarketAdditionalDataForm
|
||||
pieceId={solePieceId}
|
||||
submitLabel={getLangText('Continue to consignment')} />
|
||||
</ModalWrapper>
|
||||
|
||||
<ModalWrapper
|
||||
ref="consignModal"
|
||||
handleSuccess={handleSuccess}
|
||||
title={getLangText('Consign artwork')}>
|
||||
{consignForm}
|
||||
</ModalWrapper>
|
||||
</AclProxy>
|
||||
);
|
||||
} else {
|
||||
// Oops, well this is a difficult situation...
|
||||
// The user's likely already transferred another edition from the piece so
|
||||
// they can't update the missing fields that are necessary for consignment
|
||||
// to marketplaces.
|
||||
// Let's show an error in response to explain the problem and let them
|
||||
// contact the whitelabel themselves.
|
||||
return (
|
||||
<ModalWrapper
|
||||
trigger={triggerButton}
|
||||
handleSuccess={this.handleAdditionalDataSuccess.bind(this, solePieceId)}
|
||||
title={getLangText('Add additional information')}>
|
||||
<MarketAdditionalDataForm
|
||||
pieceId={solePieceId}
|
||||
submitLabel={getLangText('Continue to consignment')} />
|
||||
handleSuccess={this.handleConsignError}
|
||||
title={getLangText("Oops, we can't consign this piece to %s", whitelabelName)}>
|
||||
<MarketConsignError
|
||||
whitelabelName={whitelabelName} />
|
||||
</ModalWrapper>
|
||||
|
||||
<ModalWrapper
|
||||
ref="consignModal"
|
||||
handleSuccess={handleSuccess}
|
||||
title={getLangText('Consign artwork')}>
|
||||
{consignForm}
|
||||
</ModalWrapper>
|
||||
</AclProxy>
|
||||
);
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return (
|
||||
<AclProxy
|
||||
|
@ -0,0 +1,51 @@
|
||||
'use strict'
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { getLangText } from '../../../../../utils/lang_utils';
|
||||
|
||||
let MarketConsignError = React.createClass({
|
||||
propTypes: {
|
||||
handleSuccess: React.PropTypes.func,
|
||||
whitelabelName: React.PropTypes.string
|
||||
},
|
||||
|
||||
handleSuccess() {
|
||||
const { handleSuccess, whitelabelName } = this.props;
|
||||
|
||||
/* eslint-disable */
|
||||
Intercom('showNewMessage', getLangText("I'm having trouble consigning my edition to %s because I don't " +
|
||||
"have the permissions to edit its details.", whitelabelName));
|
||||
/* eslint-enable */
|
||||
|
||||
if (typeof handleSuccess === 'function') {
|
||||
handleSuccess();
|
||||
}
|
||||
},
|
||||
|
||||
render() {
|
||||
const { handleSuccess, whitelabelName } = this.props;
|
||||
|
||||
return (
|
||||
<div className="ascribe-form-error-popup">
|
||||
<div className="error-popup-content">
|
||||
<p>
|
||||
{getLangText('Unfortunately, %s requires you to provide more information ' +
|
||||
"about this edition, but it appears that you don't have the " +
|
||||
'permissions to edit the piece associated with this edition.', whitelabelName)}
|
||||
</p>
|
||||
<p>
|
||||
{getLangText('Please contact us if you would still like to consign this piece to %s.', whitelabelName)}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={this.handleSuccess}
|
||||
className="btn btn-default btn-wide">
|
||||
{getLangText('Contact us for help')}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
export default MarketConsignError;
|
@ -23,4 +23,11 @@
|
||||
@media (max-width: 550px) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ascribe-form-error-popup {
|
||||
.error-popup-content {
|
||||
margin-bottom: 30px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user