import PropTypes from 'prop-types'; import { PureComponent } from 'react'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { connect } from 'react-redux'; import Toggle from 'react-toggle'; import { muteAccount } from '../../../actions/accounts'; import { closeModal } from '../../../actions/modal'; import { toggleHideNotifications, changeMuteDuration } from '../../../actions/mutes'; import { Button } from '../../../components/button'; const messages = defineMessages({ minutes: { id: 'intervals.full.minutes', defaultMessage: '{number, plural, one {# minute} other {# minutes}}' }, hours: { id: 'intervals.full.hours', defaultMessage: '{number, plural, one {# hour} other {# hours}}' }, days: { id: 'intervals.full.days', defaultMessage: '{number, plural, one {# day} other {# days}}' }, indefinite: { id: 'mute_modal.indefinite', defaultMessage: 'Indefinite' }, }); const mapStateToProps = state => { return { account: state.getIn(['mutes', 'new', 'account']), notifications: state.getIn(['mutes', 'new', 'notifications']), muteDuration: state.getIn(['mutes', 'new', 'duration']), }; }; const mapDispatchToProps = dispatch => { return { onConfirm(account, notifications, muteDuration) { dispatch(muteAccount(account.get('id'), notifications, muteDuration)); }, onClose() { dispatch(closeModal({ modalType: undefined, ignoreFocus: false, })); }, onToggleNotifications() { dispatch(toggleHideNotifications()); }, onChangeMuteDuration(e) { dispatch(changeMuteDuration(e.target.value)); }, }; }; class MuteModal extends PureComponent { static propTypes = { account: PropTypes.object.isRequired, notifications: PropTypes.bool.isRequired, onClose: PropTypes.func.isRequired, onConfirm: PropTypes.func.isRequired, onToggleNotifications: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, muteDuration: PropTypes.number.isRequired, onChangeMuteDuration: PropTypes.func.isRequired, }; handleClick = () => { this.props.onClose(); this.props.onConfirm(this.props.account, this.props.notifications, this.props.muteDuration); }; handleCancel = () => { this.props.onClose(); }; toggleNotifications = () => { this.props.onToggleNotifications(); }; changeMuteDuration = (e) => { this.props.onChangeMuteDuration(e); }; render () { const { account, notifications, muteDuration, intl } = this.props; return (

@{account.get('acct')} }} />

:
); } } export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(MuteModal));