import { h, Component } from 'preact';
import PropTypes from 'prop-types';
/**
* TODO: Instead of calling this function in render, use jsx ().
*/
function SetupButton({ className, onClickCallback, dataContent, btnLabel }) {
return (
);
}
SetupButton.propTypes = {
className: PropTypes.string.isRequired,
onClickCallback: PropTypes.func.isRequired,
dataContent: PropTypes.string.isRequired,
btnLabel: PropTypes.string.isRequired,
};
export default class View extends Component {
static propTypes = {
onAcceptInvitation: PropTypes.func.isRequired,
onDeclineInvitation: PropTypes.func.isRequired,
onViewExit: PropTypes.func.isRequired,
channels: PropTypes.arrayOf(PropTypes.object).isRequired,
};
channel = props => {
const { onAcceptInvitation, onDeclineInvitation } = this.props;
return (
{props.channel.channel_name}
{props.channel.description}
{SetupButton({
className: 'cta',
onClickCallback: onAcceptInvitation,
dataContent: props.channel.membership_id,
btnLabel: 'Accept',
})}
{SetupButton({
className: 'cta',
onClickCallback: onDeclineInvitation,
dataContent: props.channel.membership_id,
btnLabel: 'Decline',
})}
);
};
render() {
const { onViewExit, channels: channelsFromProps } = this.props;
const channels = channelsFromProps.map(channel => {
return ;
});
return (
{SetupButton({
className: 'chatNonChatView_exitbutton',
onClickCallback: onViewExit,
dataContent: 'exit',
btnLabel: '×',
})}
Channel Invitations
{' '}
🤗
{channels}
);
}
}