2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-08-17 21:39:25 +01:00
|
|
|
import { connect } from 'react-redux'
|
2020-06-07 18:27:08 +01:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import { authorizeFollowRequest, rejectFollowRequest } from '../actions/accounts'
|
|
|
|
import { makeGetAccount } from '../selectors'
|
|
|
|
import Account from './account'
|
|
|
|
|
|
|
|
class AccountAuthorize extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
account,
|
|
|
|
onAuthorize,
|
|
|
|
onReject,
|
|
|
|
} = this.props
|
|
|
|
|
|
|
|
// <Button title={intl.formatMessage(messages.authorize)} icon='check' onClick={onAuthorize} />
|
|
|
|
// <Button title={intl.formatMessage(messages.reject)} icon='times' onClick={onReject} />
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Account
|
|
|
|
id={account.get('id')}
|
|
|
|
dismissAction={onReject}
|
|
|
|
onActionClick={onAuthorize}
|
|
|
|
actionIcon='add'
|
|
|
|
showDismiss
|
|
|
|
withBio
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-08-18 01:57:35 +01:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
authorize: { id: 'follow_request.authorize', defaultMessage: 'Authorize' },
|
|
|
|
reject: { id: 'follow_request.reject', defaultMessage: 'Reject' },
|
|
|
|
})
|
|
|
|
|
|
|
|
const makeMapStateToProps = (state, props) => ({
|
|
|
|
account: makeGetAccount()(state, props.id),
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch, { id }) => ({
|
|
|
|
onAuthorize() {
|
|
|
|
dispatch(authorizeFollowRequest(id))
|
|
|
|
},
|
|
|
|
onReject() {
|
|
|
|
dispatch(rejectFollowRequest(id))
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
AccountAuthorize.propTypes = {
|
|
|
|
account: ImmutablePropTypes.map.isRequired,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
onAuthorize: PropTypes.func.isRequired,
|
|
|
|
onReject: PropTypes.func.isRequired,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(AccountAuthorize))
|