import SendIcon from "@mui/icons-material/Send"; import { Button, TextField, useTheme } from "@mui/material"; import Grid from "@mui/material/Unstable_Grid2"; import { useState } from "react"; import { useSnackbar } from "notistack"; import postData from "../../services/api/basePostData"; export default function SendMessage({ fetchMessages }) { const [userMessage, setUserMessage] = useState(""); const { enqueueSnackbar } = useSnackbar(); const theme = useTheme(); const onMessageChange = (e) => { setUserMessage(e.target.value); }; const onPressButton = () => { const url = `/query/query_search`; if (!userMessage.trim()) { enqueueSnackbar("Please enter a message.", { variant: "warning", }); return; } const data = { q: userMessage }; postData(url, data) .then(fetchMessages) .catch((error) => { enqueueSnackbar(error.detail || error.message, { variant: "error", }); }); setUserMessage(""); }; return ( <> ); }