diff --git a/src/renderer/constants/modal_types.js b/src/renderer/constants/modal_types.js index 995060647..19b86238e 100644 --- a/src/renderer/constants/modal_types.js +++ b/src/renderer/constants/modal_types.js @@ -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'; diff --git a/src/renderer/modal/modalEmailCollection/index.js b/src/renderer/modal/modalEmailCollection/index.js new file mode 100644 index 000000000..242b9e509 --- /dev/null +++ b/src/renderer/modal/modalEmailCollection/index.js @@ -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); diff --git a/src/renderer/modal/modalEmailCollection/view.jsx b/src/renderer/modal/modalEmailCollection/view.jsx new file mode 100644 index 000000000..a17ecf7df --- /dev/null +++ b/src/renderer/modal/modalEmailCollection/view.jsx @@ -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 = ; + + if (!user.has_verified_email && !email) { + return ; + } else if (!user.has_verified_email) { + return ; + } + closeModal(); + } + + render() { + const { user } = this.props; + + // this shouldn't happen + if (!user) { + return null; + } + + return ( + +
+

Can We Stay In Touch?

+ {this.renderInner()} +
+
+ ); + } +} + +export default ModalEmailCollection; diff --git a/src/renderer/modal/modalRouter/view.jsx b/src/renderer/modal/modalRouter/view.jsx index ac254ed6d..b84272a6c 100644 --- a/src/renderer/modal/modalRouter/view.jsx +++ b/src/renderer/modal/modalRouter/view.jsx @@ -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 ; case modals.PHONE_COLLECTION: return ; + case modals.EMAIL_COLLECTION: + return ; default: return null; }