Skip to content

Instantly share code, notes, and snippets.

@jetaggart
Created August 3, 2020 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jetaggart/e4cb88fbb40a72ab5376f96161a4034f to your computer and use it in GitHub Desktop.
Save jetaggart/e4cb88fbb40a72ab5376f96161a4034f to your computer and use it in GitHub Desktop.
// frontend/src/SalesChat.js:7
function SalesChat({ username, leadId, chatClient, channel }) {
async function handleMessage(_channelId, message) {
await axios.post("http://localhost:8080/messages", { message, author: username, leadId: leadId });
return channel.sendMessage(message);
}
return (
<Chat client={chatClient} theme="commerce light">
<Channel channel={channel} doSendMessageRequest={handleMessage}>
<Window>
<h1>
Customer Support Chat: {channel.id}
</h1>
<MessageList/>
<MessageInput focus/>
</Window>
</Channel>
</Chat>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment