diff --git a/src/components/profile/profileView.js b/src/components/profile/profileView.js index 5f58523ef..260931b82 100644 --- a/src/components/profile/profileView.js +++ b/src/components/profile/profileView.js @@ -97,6 +97,7 @@ class ProfileView extends PureComponent { handleOnFavoritePress, handleOnFollowsPress, handleOnPressProfileEdit, + handleReportUser, intl, isDarkTheme, isFavorite, @@ -137,6 +138,7 @@ class ProfileView extends PureComponent { handleMuteUnmuteUser={handleMuteUnmuteUser} handleOnFavoritePress={handleOnFavoritePress} handleOnFollowsPress={handleOnFollowsPress} + handleReportUser={handleReportUser} handleUIChange={this._handleUIChange} hoursRC={Math.ceil((100 - resourceCredits) * 0.833333) || null} hoursVP={Math.ceil((100 - votingPower) * 0.833333) || null} diff --git a/src/components/profileSummary/view/profileSummaryView.js b/src/components/profileSummary/view/profileSummaryView.js index 0db0e3319..2a005faed 100644 --- a/src/components/profileSummary/view/profileSummaryView.js +++ b/src/components/profileSummary/view/profileSummaryView.js @@ -57,7 +57,13 @@ class ProfileSummaryView extends PureComponent { }; _handleOnDropdownSelect = (index) => { - const { isMuted, isFavorite, handleMuteUnmuteUser, handleOnFavoritePress } = this.props; + const { + isMuted, + isFavorite, + handleMuteUnmuteUser, + handleOnFavoritePress, + handleReportUser, + } = this.props; switch (index) { case 0: @@ -70,6 +76,11 @@ class ProfileSummaryView extends PureComponent { handleMuteUnmuteUser(!isMuted); } break; + case 2: + if (handleReportUser) { + handleReportUser(); + } + break; default: Alert.alert('Action not implemented'); break; @@ -101,7 +112,7 @@ class ProfileSummaryView extends PureComponent { percentVP, username, } = this.props; - const dropdownOptions = []; + let dropdownOptions = []; const votingPowerHoursText = hoursVP && `• Full in ${hoursVP} hours`; const votingPowerText = `Voting power: ${percentVP}% ${votingPowerHoursText || ''}`; const rcPowerHoursText = hoursRC && `• Full in ${hoursRC} hours`; @@ -133,16 +144,17 @@ class ProfileSummaryView extends PureComponent { } //compile dropdown options - dropdownOptions.push( + dropdownOptions = [ intl.formatMessage({ id: isFavorite ? 'user.remove_from_favourites' : 'user.add_to_favourites', }), - ); - dropdownOptions.push( intl.formatMessage({ id: !isMuted ? 'user.mute' : 'user.unmute', }), - ); + intl.formatMessage({ + id: 'user.report', + }), + ]; return ( diff --git a/src/containers/profileContainer.js b/src/containers/profileContainer.js index ec17e1ac1..dcc9cd41e 100644 --- a/src/containers/profileContainer.js +++ b/src/containers/profileContainer.js @@ -20,11 +20,11 @@ import { } from '../providers/hive/dhive'; // Ecency providers -import { checkFavorite, addFavorite, deleteFavorite } from '../providers/ecency/ecency'; +import { checkFavorite, addFavorite, deleteFavorite, addReport } from '../providers/ecency/ecency'; // Utilitites import { getRcPower, getVotingPower } from '../utils/manaBar'; -import { toastNotification, setRcOffer } from '../redux/actions/uiAction'; +import { toastNotification, setRcOffer, showActionModal } from '../redux/actions/uiAction'; // Constants import { default as ROUTES } from '../constants/routeNames'; @@ -407,6 +407,50 @@ class ProfileContainer extends Component { }); }; + _handleReportUser = () => { + const { dispatch, intl } = this.props; + const { username } = this.state; + + const _onConfirm = () => { + addReport('user', username) + .then(() => { + dispatch( + toastNotification( + intl.formatMessage({ + id: 'report.added', + }), + ), + ); + }) + .catch(() => { + dispatch( + toastNotification( + intl.formatMessage({ + id: 'report.added', + }), + ), + ); + }); + }; + + dispatch( + showActionModal( + intl.formatMessage({ id: 'report.confirm_report_title' }), + intl.formatMessage({ id: 'report.confirm_report_body' }), + [ + { + text: intl.formatMessage({ id: 'alert.cancel' }), + onPress: () => {}, + }, + { + text: intl.formatMessage({ id: 'alert.confirm' }), + onPress: _onConfirm, + }, + ], + ), + ); + }; + _handleOnBackPress = () => { const { navigation } = this.props; const navigationParams = get(navigation.state, 'params'); @@ -516,6 +560,7 @@ class ProfileContainer extends Component { handleOnFavoritePress: this._handleOnFavoritePress, handleOnFollowsPress: this._handleFollowsPress, handleOnPressProfileEdit: this._handleOnPressProfileEdit, + handleReportUser: this._handleReportUser, isDarkTheme, isFavorite, isFollowing, diff --git a/src/screens/profile/screen/profileScreen.js b/src/screens/profile/screen/profileScreen.js index 5e5467919..f40b14dab 100644 --- a/src/screens/profile/screen/profileScreen.js +++ b/src/screens/profile/screen/profileScreen.js @@ -24,6 +24,7 @@ const ProfileScreen = () => ( handleOnFavoritePress, handleOnFollowsPress, handleOnPressProfileEdit, + handleReportUser, isDarkTheme, isFavorite, isFollowing, @@ -61,6 +62,7 @@ const ProfileScreen = () => ( handleOnFavoritePress={handleOnFavoritePress} handleOnFollowsPress={handleOnFollowsPress} handleOnPressProfileEdit={handleOnPressProfileEdit} + handleReportUser={handleReportUser} isDarkTheme={isDarkTheme} isFavorite={isFavorite} isFollowing={isFollowing}