diff --git a/client/coral-admin/src/components/RejectUsernameDialog.js b/client/coral-admin/src/components/RejectUsernameDialog.js index cdd211bc4..a15d5e02a 100644 --- a/client/coral-admin/src/components/RejectUsernameDialog.js +++ b/client/coral-admin/src/components/RejectUsernameDialog.js @@ -1,23 +1,15 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Dialog } from 'coral-ui'; -import { RadioGroup, Radio } from 'react-mdl'; import styles from './SuspendUserDialog.css'; import cn from 'classnames'; - +import { RadioGroup, Radio } from 'react-mdl'; import Button from 'coral-ui/components/Button'; +import { username as flagReason } from 'coral-framework/graphql/flagReasons'; -import t, { timeago } from 'coral-framework/services/i18n'; -import { dateAdd } from 'coral-framework/utils'; +const initialState = { reason: flagReason.offensive, message: '' }; -const initialState = { step: 0, duration: '3' }; - -function durationsToDate(hours) { - // Add 1 minute more to help `timeago.js` to display the correct duration. - return dateAdd(new Date(), 'minute', hours * 60 + 1); -} - -class SuspendUserDialog extends React.Component { +class RejectUsernameDialog extends React.Component { state = initialState; componentWillReceiveProps(next) { @@ -26,138 +18,28 @@ class SuspendUserDialog extends React.Component { } } - handleDurationChange = event => { - this.setState({ duration: event.target.value }); + handleReasonChange = event => { + this.setState({ reason: event.target.value }); }; handleMessageChange = event => { this.setState({ message: event.target.value }); }; - goToStep1 = () => { - this.setState({ - step: 1, - message: t( - 'suspenduser.email_message_suspend', - this.props.username, - this.props.organizationName, - timeago(durationsToDate(this.state.duration)) - ), - }); - }; - handlePerform = () => { this.props.onPerform({ + reason: this.state.reason, message: this.state.message, - - // Add 1 minute more to help `timeago.js` to display the correct duration. - until: durationsToDate(this.state.duration), }); }; - renderStep0() { - const { onCancel, username } = this.props; - const { duration } = this.state; - return ( -
-

{t('suspenduser.title_suspend')}

-

- {t('suspenduser.description_suspend', username)} -

-
- - {t('suspenduser.select_duration')} - - - {t('suspenduser.one_hour')} - {t('suspenduser.hours', 3)} - {t('suspenduser.hours', 24)} - {t('suspenduser.days', 7)} - -
-
- - -
-
- ); - } - - renderStep1() { - const { message } = this.state; - const { onCancel, username } = this.props; - return ( -
-

{t('suspenduser.title_notify')}

-

- {t('suspenduser.description_notify', username)} -

-
- - {t('suspenduser.write_message')} - -