import { h, Component } from 'preact'; import twitterImage from 'images/twitter-logo.svg'; import githubImage from 'images/github-logo.svg'; import websiteImage from 'images/external-link-logo.svg'; function blockUser(blockedUserId) { const body = { user_block: { blocked_id: blockedUserId, }, }; getCsrfToken().then(sendFetch('block-user', JSON.stringify(body))); } const setUpButton = ({ modalId = '', otherModalId = '', btnName = '' }) => { return ( ); }; const userDetailsConfig = { twitter_username: { hostUrl: 'https://twitter.com/', srcImage: twitterImage, imageAltText: 'twitter logo', }, github_username: { hostUrl: 'https://github.com/', srcImage: githubImage, imageAltText: 'github logo', }, website_url: { className: 'external-link-img', hostUrl: '', srcImage: websiteImage, imageAltText: 'external link icon', }, }; export default class UserDetails extends Component { render() { const { user } = this.props; const channelId = this.props.activeChannelId; const channel = this.props.activeChannel || {}; const socialIcons = []; const userMeta = ['twitter_username', 'github_username', 'website_url']; userMeta.forEach(metaProp => { if (user[metaProp]) { const { className, hostUrl, srcImage, imageAltText, } = userDetailsConfig[metaProp]; socialIcons.push( {imageAltText} , ); } }); let userLocation = ''; if (user.location && user.location.length > 0) { userLocation = (
location
{user.location}
); } let blockButton = ''; if (channel.channel_type === 'direct' && window.currentUser.id != user.id) { blockButton = setUpButton({ modalId: 'userdetails__blockmsg', otherModalId: 'userdetails__reportabuse', btnName: 'Block User', }); } let reportButton = ''; if (window.currentUser.id !== user.id) { reportButton = setUpButton({ modalId: 'userdetails__reportabuse', otherModalId: 'userdetails__blockmsg', btnName: 'Report Abuse', }); } return (
{`${user.username}

{user.name}

{socialIcons}
{user.summary}
{userLocation}
joined
{user.joined_at}
{blockButton} {reportButton}

Reporting abuse will:

  • close this chat and prevent this user from re-opening chat with you
  • give the DEV team your consent to read messages in this chat to understand your report and take appropriate action

Blocking is only on Connect right now and has not been implemented across DEV yet.

Are you sure?
{ blockUser(channelId); }} > Yes, Report { document.getElementById( 'userdetails__reportabuse', ).style.display = 'none'; window.location.href = `#`; }} onKeyUp={e => { if (e.keyCode === 13) { document.getElementById( 'userdetails__reportabuse', ).style.display = 'none'; window.location.href = `#`; } }} > No

Blocking on connect will:

  • close this chat and prevent this user from re-opening chat with you
  • NOT notify the user you will block--this channel will become inaccessible for both users

Blocking is only on Connect right now and has not been implemented across DEV yet. Consider reporting abuse to the DEV team if this user is spamming or harassing elsewhere on dev.to, so we can take further action.

Are you sure?
{ blockUser(user.id); window.location.href = `/connect`; }} onKeyUp={e => { if (e.keyCode === 13) { blockUser(user.id); window.location.href = `/connect`; } }} > Yes, Block { document.getElementById('userdetails__blockmsg').style.display = 'none'; window.location.href = `#`; }} onKeyUp={e => { if (e.keyCode === 13) { document.getElementById( 'userdetails__blockmsg', ).style.display = 'none'; window.location.href = `#`; } }} > No
); } }