import { h } from 'preact'; import { useState } from 'preact/hooks'; import PropTypes from 'prop-types'; import { createChannel } from '../actions/chat_channel_setting_actions'; import { addSnackbarItem } from '../../Snackbar'; import { Modal, Button } from '@crayons'; /** * * This component is used to create a chat channel. At the moment only support for tag_moderator user types. * * @param {object} props * @param {function} props.toggleModalCreateChannel * @param {function} props.handleCreateChannelSuccess * * @component * * @example * * * */ export function CreateChatModal({ toggleModalCreateChannel, handleCreateChannelSuccess, }) { const [channelName, setchannelName] = useState(undefined); const [userNames, setUserNames] = useState(undefined); const handleCreateChannel = async (e) => { e.preventDefault(); const result = await createChannel(channelName, userNames); if (result.success) { handleCreateChannelSuccess(); addSnackbarItem({ message: result.message }); } else { addSnackbarItem({ message: result.message }); } }; return ( Channel Name setchannelName(e.target.value)} /> Invite Users setUserNames(e.target.value)} /> Create ); } CreateChatModal.propTypes = { toggleModalCreateChannel: PropTypes.func.isRequired, handleCreateChannelSuccess: PropTypes.func.isRequired, };