Kaynağa Gözat

Merge pull request #2341 from visuddhinanda/development

未登录不能使用ai chat
visuddhinanda 8 ay önce
ebeveyn
işleme
83f6b2b440

+ 7 - 1
dashboard-v4/dashboard/src/components/chat/AiChat.tsx

@@ -23,6 +23,8 @@ import MsgLoading from "./MsgLoading";
 import MsgSystem from "./MsgSystem";
 import MsgError from "./MsgError";
 import PromptButtonGroup from "./PromptButtonGroup";
+import { useAppSelector } from "../../hooks";
+import { currentUser } from "../../reducers/current-user";
 
 const { TextArea } = Input;
 
@@ -90,6 +92,8 @@ const AIChatComponent = ({
 
   const [error, setError] = useState<string>();
 
+  const user = useAppSelector(currentUser);
+
   const scrollToBottom = useCallback(() => {
     messagesEndRef.current?.scrollIntoView({
       behavior: "smooth",
@@ -444,7 +448,7 @@ const AIChatComponent = ({
     })),
   };
 
-  return (
+  return user ? (
     <div
       style={{
         display: "flex",
@@ -555,6 +559,8 @@ const AIChatComponent = ({
         </Card>
       </Affix>
     </div>
+  ) : (
+    <></>
   );
 };