Readded email collection modal and trigger at startup
This commit is contained in:
parent
9e2d82eac8
commit
e0de34d433
4 changed files with 82 additions and 4 deletions
|
@ -6,6 +6,7 @@ export const ERROR = 'error';
|
|||
export const INSUFFICIENT_CREDITS = 'insufficient_credits';
|
||||
export const UPGRADE = 'upgrade';
|
||||
export const WELCOME = 'welcome';
|
||||
export const EMAIL_COLLECTION = 'email_collection';
|
||||
export const PHONE_COLLECTION = 'phone_collection';
|
||||
export const FIRST_REWARD = 'first_reward';
|
||||
export const AUTHENTICATION_FAILURE = 'auth_failure';
|
||||
|
|
21
src/renderer/modal/modalEmailCollection/index.js
Normal file
21
src/renderer/modal/modalEmailCollection/index.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
import React from 'react';
|
||||
import * as settings from 'constants/settings';
|
||||
import { connect } from 'react-redux';
|
||||
import { doCloseModal } from 'redux/actions/app';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { selectEmailToVerify, selectUser } from 'redux/selectors/user';
|
||||
import ModalEmailCollection from './view';
|
||||
|
||||
const select = state => ({
|
||||
email: selectEmailToVerify(state),
|
||||
user: selectUser(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => () => ({
|
||||
closeModal: () => {
|
||||
dispatch(doSetClientSetting(settings.EMAIL_COLLECTION_ACKNOWLEDGED, true));
|
||||
dispatch(doCloseModal());
|
||||
},
|
||||
});
|
||||
|
||||
export default connect(select, perform)(ModalEmailCollection);
|
40
src/renderer/modal/modalEmailCollection/view.jsx
Normal file
40
src/renderer/modal/modalEmailCollection/view.jsx
Normal file
|
@ -0,0 +1,40 @@
|
|||
import React from 'react';
|
||||
import { Modal } from 'modal/modal';
|
||||
import Link from 'component/link/index';
|
||||
import UserEmailNew from 'component/userEmailNew';
|
||||
import UserEmailVerify from 'component/userEmailVerify';
|
||||
|
||||
class ModalEmailCollection extends React.PureComponent {
|
||||
renderInner() {
|
||||
const { closeModal, email, user } = this.props;
|
||||
|
||||
const cancelButton = <Link button="text" onClick={closeModal} label={__('Not Now')} />;
|
||||
|
||||
if (!user.has_verified_email && !email) {
|
||||
return <UserEmailNew cancelButton={cancelButton} />;
|
||||
} else if (!user.has_verified_email) {
|
||||
return <UserEmailVerify cancelButton={cancelButton} />;
|
||||
}
|
||||
closeModal();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { user } = this.props;
|
||||
|
||||
// this shouldn't happen
|
||||
if (!user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal type="custom" isOpen contentLabel="Email">
|
||||
<section>
|
||||
<h3 className="modal__header">Can We Stay In Touch?</h3>
|
||||
{this.renderInner()}
|
||||
</section>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ModalEmailCollection;
|
|
@ -12,6 +12,7 @@ import ModalTransactionFailed from 'modal/modalTransactionFailed';
|
|||
import ModalFileTimeout from 'modal/modalFileTimeout';
|
||||
import ModalAffirmPurchase from 'modal/modalAffirmPurchase';
|
||||
import ModalRevokeClaim from 'modal/modalRevokeClaim';
|
||||
import ModalEmailCollection from '../modalEmailCollection';
|
||||
import ModalPhoneCollection from '../modalPhoneCollection';
|
||||
import * as modals from 'constants/modal_types';
|
||||
|
||||
|
@ -40,10 +41,11 @@ class ModalRouter extends React.PureComponent {
|
|||
return;
|
||||
}
|
||||
|
||||
const transitionModal = [this.checkShowWelcome, this.checkShowCreditIntro].reduce(
|
||||
(acc, func) => (!acc ? func.bind(this)(props) : acc),
|
||||
false
|
||||
);
|
||||
const transitionModal = [
|
||||
this.checkShowWelcome,
|
||||
this.checkShowEmail,
|
||||
this.checkShowCreditIntro,
|
||||
].reduce((acc, func) => (!acc ? func.bind(this)(props) : acc), false);
|
||||
|
||||
if (
|
||||
transitionModal &&
|
||||
|
@ -64,6 +66,18 @@ class ModalRouter extends React.PureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
checkShowEmail(props) {
|
||||
const { isEmailCollectionAcknowledged, isVerificationCandidate, user } = props;
|
||||
if (
|
||||
!isEmailCollectionAcknowledged &&
|
||||
isVerificationCandidate &&
|
||||
user &&
|
||||
!user.has_verified_email
|
||||
) {
|
||||
return modals.EMAIL_COLLECTION;
|
||||
}
|
||||
}
|
||||
|
||||
checkShowCreditIntro(props) {
|
||||
const { balance, page, isCreditIntroAcknowledged } = props;
|
||||
|
||||
|
@ -113,6 +127,8 @@ class ModalRouter extends React.PureComponent {
|
|||
return <ModalRevokeClaim {...modalProps} />;
|
||||
case modals.PHONE_COLLECTION:
|
||||
return <ModalPhoneCollection {...modalProps} />;
|
||||
case modals.EMAIL_COLLECTION:
|
||||
return <ModalEmailCollection {...modalProps} />;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue