2017-06-08_509bba0/509bba0_unpacked_with_node_modules/discord_app/components/GuildVerification.js
2022-07-26 10:06:20 -07:00

78 lines
3 KiB
JavaScript
Executable file

import React from 'react';
import i18n from '../i18n';
import Flux from '../lib/flux';
import {UserSettingsSections, VerificationCriteria} from '../Constants';
import ChannelTextAreaGuard from './ChannelTextAreaGuard';
import ConfirmModal from './ConfirmModal';
import PhoneVerificationModal from './verification/PhoneVerificationModal';
import UserStore from '../stores/UserStore';
import GuildVerificationStore from '../stores/GuildVerificationStore';
import UserSettingsModalActionCreators from '../actions/UserSettingsModalActionCreators';
import AuthenticationActionCreators from '../actions/AuthenticationActionCreators';
import ModalActionCreators from '../actions/ModalActionCreators';
const GuildVerification = React.createClass({
mixins: [Flux.StoreListenerMixin(GuildVerificationStore)],
getStateFromStores() {
return GuildVerificationStore.getCheck(this.props.channel.getGuildId());
},
componentWillReceiveProps(nextProps) {
this.setState(GuildVerificationStore.getCheck(nextProps.channel.getGuildId()));
},
handleClaimAccount() {
UserSettingsModalActionCreators.open(UserSettingsSections.ACCOUNT);
},
handleVerifyPhone() {
ModalActionCreators.push(props => <PhoneVerificationModal {...props} />);
},
handleResendVerification() {
AuthenticationActionCreators.verifyResend();
ModalActionCreators.push(props => {
return (
<ConfirmModal
header={i18n.Messages.VERIFICATION_EMAIL_TITLE}
confirmText={i18n.Messages.OKAY}
red={false}
{...props}>
<p>{i18n.Messages.VERIFICATION_EMAIL_BODY.format({email: UserStore.getCurrentUser().email})}</p>
</ConfirmModal>
);
});
},
render() {
const props = {};
if (this.state.notClaimed) {
props.message = i18n.Messages.GUILD_VERIFICATION_TEXT_NOT_CLAIMED;
props.buttonText = i18n.Messages.CLAIM_ACCOUNT;
props.onButtonClick = this.handleClaimAccount;
} else if (this.state.notPhoneVerified) {
props.message = i18n.Messages.GUILD_VERIFICATION_TEXT_NOT_PHONE_VERIFIED;
props.buttonText = i18n.Messages.VERIFY_PHONE;
props.onButtonClick = this.handleVerifyPhone;
} else if (this.state.notEmailVerified) {
props.message = i18n.Messages.GUILD_VERIFICATION_TEXT_NOT_VERIFIED;
props.buttonText = i18n.Messages.RESEND_VERIFICATION_EMAIL;
props.onButtonClick = this.handleResendVerification;
} else if (this.state.newAccount) {
props.message = i18n.Messages.GUILD_VERIFICATION_TEXT_ACCOUNT_AGE.format({min: VerificationCriteria.ACCOUNT_AGE});
props.countdown = this.state.accountDeadline;
} else if (this.state.newMember) {
props.message = i18n.Messages.GUILD_VERIFICATION_TEXT_MEMBER_AGE.format({min: VerificationCriteria.MEMBER_AGE});
props.countdown = this.state.memberDeadline;
}
return <ChannelTextAreaGuard {...props}>{this.props.children}</ChannelTextAreaGuard>;
},
});
export default GuildVerification;
// WEBPACK FOOTER //
// ./discord_app/components/GuildVerification.js