/* * @Author : Eleanor Mao * @Date : 2024-04-09 10:36:44 * @LastEditTime : 2024-04-09 10:36:44 * * */ import React, { ChangeEvent, KeyboardEvent, useEffect, useRef, useState } from "react"; import Grid from '@mui/material/Grid'; import Box from '@mui/material/Box'; import Button from '@mui/material/Button'; import TextField from '@mui/material/TextField'; import OutlinedInput from '@mui/material/OutlinedInput'; import SendIcon from '@mui/icons-material/Send'; import List from '@mui/material/List'; import Chip from '@mui/material/Chip'; import Divider from '@mui/material/Divider'; import { ChatItem } from "./ChatItem"; import Stack from '@mui/material/Stack'; import { uniqueId } from 'lodash'; import Typography from "@mui/material/Typography"; import { Editor } from "./Editor"; interface Message { id: string; message: string; isMe: boolean; } const SupportedBlock = ['BotMessage', 'Chat', 'EmailSender', 'Script']; export const Create = () => { const [chatList, setChatList] = useState([]); const [workflowName, setWorkFlowName] = useState('My workflow'); const [chatInput, setChatInput] = useState(''); const chatContentRef = useRef(null); const handleChange = (e: ChangeEvent) => { setChatInput(e.target.value); }; const handleClickChip = (text: string) => () => { setChatInput(s => s + text); }; const handleSend = () => { setChatList([...chatList, { id: uniqueId(), message: chatInput, isMe: true }]); setChatInput(''); }; useEffect(() => { if (chatContentRef.current) { chatContentRef.current.scrollTop = chatContentRef.current.scrollHeight - chatContentRef.current.offsetHeight; } }, [chatList]); return ( <> { setWorkFlowName(e.target.value); }}/>
{chatList.map(chat => )} Supported Action Types: {SupportedBlock.map(label => ( ))} ) => { if (e.key === 'Enter' && chatInput.length) { e.preventDefault(); handleSend(); } }} multiline maxRows={3} value={chatInput}/>
Preview
); };