diff --git a/src/pages/dashboard/Content/Support/Chat/Chat.tsx b/src/pages/dashboard/Content/Support/Chat/Chat.tsx
index 46d8df3..cfcbc9e 100644
--- a/src/pages/dashboard/Content/Support/Chat/Chat.tsx
+++ b/src/pages/dashboard/Content/Support/Chat/Chat.tsx
@@ -1,4 +1,4 @@
-import { Box, IconButton, InputAdornment, TextField, useMediaQuery, useTheme } from "@mui/material";
+import { Box, IconButton, InputAdornment, TextField, Typography, useMediaQuery, useTheme } from "@mui/material";
import { addOrUpdateMessage, setMessages, useMessageStore } from "@root/stores/messages";
import Message from "./Message";
import SendIcon from "@mui/icons-material/Send";
@@ -27,13 +27,13 @@ export default function Chat() {
}, [messages]);
useEffect(function fetchTicketMessages() {
- if (!ticketId) return;
+ if (!ticket) return;
const getTicketsBody: GetMessagesRequest = {
amt: 100, // TODO use pagination
page: 0,
srch: "",
- ticket: ticketId,
+ ticket: ticket.id,
};
const controller = new AbortController();
@@ -50,16 +50,16 @@ export default function Chat() {
});
return () => controller.abort();
- }, [ticketId]);
+ }, [ticket]);
useEffect(function subscribeToMessages() {
- if (!ticketId) return;
+ if (!ticket) return;
const token = localStorage.getItem("AT");
if (!token) return;
const unsubscribe = subscribeToTicketMessages({
- ticketId,
+ ticketId: ticket.id,
accessToken: token,
onMessage(event) {
try {
@@ -79,7 +79,7 @@ export default function Chat() {
return () => {
unsubscribe();
};
- }, [ticketId]);
+ }, [ticket]);
function scrollToBottom() {
if (!chatBoxRef.current) return;
@@ -92,14 +92,14 @@ export default function Chat() {
}
function handleSendMessage() {
- if (!ticketId || !messageField) return;
+ if (!ticket || !messageField) return;
sendTicketMessage({
body: {
files: [],
lang: "ru",
message: messageField,
- ticket: ticketId,
+ ticket: ticket.id,
}
});
setMessageField("");
@@ -128,70 +128,79 @@ export default function Chat() {
display: "flex",
flex: upMd ? "2 0 0" : undefined,
flexDirection: "column",
+ justifyContent: "center",
+ alignItems: "center",
gap: "8px",
}}>
-
- {ticket && sortedMessages.map(message =>
-
- )}
-
- setMessageField(e.target.value)}
- onKeyPress={handleTextfieldKeyPress}
- id="message-input"
- placeholder="Написать сообщение"
- fullWidth
- multiline
- maxRows={8}
- InputProps={{
- style: {
- backgroundColor: theme.palette.content.main,
- color: theme.palette.secondary.main,
- },
- endAdornment: (
-
-
-
-
-
-
-
-
- )
- }}
- InputLabelProps={{
- style: {
- color: theme.palette.secondary.main,
- }
- }}
- />
+ {ticket ?
+ <>
+ {ticket.title}
+
+ {sortedMessages.map(message =>
+
+ )}
+
+ setMessageField(e.target.value)}
+ onKeyPress={handleTextfieldKeyPress}
+ id="message-input"
+ placeholder="Написать сообщение"
+ fullWidth
+ multiline
+ maxRows={8}
+ InputProps={{
+ style: {
+ backgroundColor: theme.palette.content.main,
+ color: theme.palette.secondary.main,
+ },
+ endAdornment: (
+
+
+
+
+
+
+
+
+ )
+ }}
+ InputLabelProps={{
+ style: {
+ color: theme.palette.secondary.main,
+ }
+ }}
+ />
+ >
+ :
+ Выберите тикет}
);
}