Implement Require Email for Notifications on Frontend

This commit is contained in:
Chi Vinh Le
2018-03-05 17:12:05 +01:00
parent 8113c4f8b8
commit 047beb1ae9
17 changed files with 312 additions and 10 deletions
@@ -0,0 +1,35 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { withResendEmailConfirmation } from 'plugin-api/beta/client/hocs';
import { compose } from 'recompose';
import EmailVerificationBanner from '../components/EmailVerificationBanner';
class EmailVerificationBannerContainer extends Component {
handleResendEmailVerification = () => {
this.props.resendEmailConfirmation(this.props.email);
};
render() {
return (
<EmailVerificationBanner
onResendEmailVerification={this.handleResendEmailVerification}
errorMessage={this.props.errorMessage}
success={this.props.success}
loading={this.props.loading}
email={this.props.email}
/>
);
}
}
EmailVerificationBannerContainer.propTypes = {
success: PropTypes.bool.isRequired,
loading: PropTypes.bool.isRequired,
resendEmailConfirmation: PropTypes.func.isRequired,
errorMessage: PropTypes.string,
email: PropTypes.string.isRequired,
};
export default compose(withResendEmailConfirmation)(
EmailVerificationBannerContainer
);
@@ -31,6 +31,12 @@ class SettingsContainer extends React.Component {
this.props.updateNotificationSettings(this.state.turnOffInput);
};
getNeedEmailVerification() {
return !this.props.root.me.profiles.some(
profile => profile.provider === 'local' && profile.confirmedAt
);
}
render() {
return (
<Settings
@@ -42,6 +48,8 @@ class SettingsContainer extends React.Component {
updateNotificationSettings={this.props.updateNotificationSettings}
turnOffAll={this.turnOffAll}
turnOffButtonDisabled={this.state.hasNotifications.length === 0}
needEmailVerification={this.getNeedEmailVerification()}
email={this.props.root.me.email}
/>
);
}
@@ -60,6 +68,7 @@ const enhance = compose(
__typename
${getSlotFragmentSpreads(slots, 'root')}
me {
email
profiles {
provider
... on LocalUserProfile {