mirror of
https://github.com/wassname/talk.git
synced 2026-08-20 12:50:41 +08:00
Implement Require Email for Notifications on Frontend
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user