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]) { let { 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', }); } return (
{`${user.username}

{user.name}

{socialIcons}
{user.summary}
{userLocation}
joined
{user.joined_at}
{blockButton} {setUpButton({ modalId: 'userdetails__reportabuse', otherModalId: 'userdetails__blockmsg', btnName: 'Report Abuse', })}
); } }