2020-06-12 22:55:39 +01:00
import { FormattedMessage } from 'react-intl'
import ImmutablePureComponent from 'react-immutable-pure-component'
import ImmutablePropTypes from 'react-immutable-proptypes'
import { unfollowAccount } from '../../actions/accounts'
import ConfirmationModal from './confirmation_modal'
2020-03-24 04:39:12 +00:00
2020-04-11 23:29:19 +01:00
const mapDispatchToProps = ( dispatch ) => ( {
2020-06-12 22:55:39 +01:00
onConfirm ( accountId ) {
dispatch ( unfollowAccount ( accountId ) )
2020-04-11 23:29:19 +01:00
} ,
} )
2020-03-24 04:39:12 +00:00
export default
2020-06-12 22:55:39 +01:00
@ connect ( null , mapDispatchToProps )
class UnfollowModal extends ImmutablePureComponent {
2020-03-24 04:39:12 +00:00
static propTypes = {
isSubmitting : PropTypes . bool . isRequired ,
2020-06-12 22:55:39 +01:00
account : ImmutablePropTypes . map . isRequired ,
2020-03-24 04:39:12 +00:00
onConfirm : PropTypes . func . isRequired ,
2020-04-07 02:53:23 +01:00
onClose : PropTypes . func . isRequired ,
2020-03-24 04:39:12 +00:00
}
handleClick = ( ) => {
this . props . onClose ( )
2020-06-12 22:55:39 +01:00
this . props . onConfirm ( this . props . account . get ( 'id' ) )
2020-03-24 04:39:12 +00:00
}
handleCancel = ( ) => {
this . props . onClose ( )
}
render ( ) {
2020-06-12 22:55:39 +01:00
const { account } = this . props
2020-03-24 04:39:12 +00:00
return (
< ConfirmationModal
2020-06-12 22:55:39 +01:00
title = { ` Unfollow @ ${ account . get ( 'acct' ) } ` }
message = { < FormattedMessage id = 'confirmations.unfollow.message' defaultMessage = 'Are you sure you want to unfollow {name}?' values = { { name : < strong > @ { account . get ( 'acct' ) } < /strong> }} / > }
confirm = { < FormattedMessage id = 'confirmations.unfollow.confirm' defaultMessage = 'Unfollow' / > }
onClose = { this . handleCancel }
onConfirm = { this . handleClick }
2020-03-24 04:39:12 +00:00
/ >
)
}
}