diff --git a/frontend/src/components/Header/Chat.tsx b/frontend/src/components/Header/Chat.tsx index c30de217..b959219b 100644 --- a/frontend/src/components/Header/Chat.tsx +++ b/frontend/src/components/Header/Chat.tsx @@ -7,7 +7,7 @@ import ErrorMessage from "../ErrorMessage"; import ConversationList from "./ConversationList"; import { extractContentFromDOM } from "../../services/domExtraction"; import axios from "axios"; -import { FaPlus, FaMinus, FaTimes, FaComment, FaComments, FaPills, FaLightbulb, FaArrowCircleDown } from "react-icons/fa"; +import { FaPlus, FaMinus, FaTimes, FaComment, FaComments, FaPills, FaLightbulb, FaArrowCircleDown, FaExpandAlt, FaExpandArrowsAlt } from "react-icons/fa"; import { fetchConversations, continueConversation, @@ -72,13 +72,6 @@ const Chat: React.FC = ({ showChat, setShowChat }) => { setPageContent(extractedContent); }, []); - // useEffect(() => { - // if (chatContainerRef.current) { - // const chatContainer = chatContainerRef.current; - // chatContainer.scrollTop = chatContainer.scrollHeight; - // } - // }, [chatLog]); - const [bottom, setBottom] = useState(false); const handleScroll = (event: React.UIEvent) => { @@ -87,6 +80,8 @@ const Chat: React.FC = ({ showChat, setShowChat }) => { setBottom(bottom) }; + const [expandChat, setExpandChat] = useState(false); + useEffect(() => { if (chatContainerRef.current && activeConversation) { const chatContainer = chatContainerRef.current; @@ -204,52 +199,6 @@ const Chat: React.FC = ({ showChat, setShowChat }) => { } }; - // const systemMessage = { - // role: "system", - // content: "You are a bot please keep conversation going.", - // }; - // const sendMessage = (message: ChatLogItem[]) => { - // const baseUrl = import.meta.env.VITE_API_BASE_URL; - // const url = `${baseUrl}/chatgpt/chat`; - - // const apiMessages = message.map((messageObject) => { - // let role = ""; - // if (messageObject.is_user) { - // role = "user"; - // } else { - // role = "assistant"; - // } - // return { role: role, content: messageObject.content }; - // }); - - // systemMessage.content += `If applicable, please use the following content to ask questions. If not applicable, - // please answer to the best of your ability: ${pageContent}`; - - // const apiRequestBody = { - // prompt: [systemMessage, ...apiMessages], - // }; - - // setIsLoading(true); - - // axios - // .post(url, apiRequestBody) - // .then((response) => { - // console.log(response); - // setChatLog((prevChatLog) => [ - // ...prevChatLog, - // { - // is_user: false, - // content: response.data.message.choices[0].message.content, - // }, - // ]); - // setIsLoading(false); - // }) - // .catch((error) => { - // setIsLoading(false); - // console.log(error); - // }); - // }; - const handleSelectConversation = (id: Conversation["id"]) => { const selectedConversation = conversations.find( (conversation: any) => conversation.id === id, @@ -267,13 +216,25 @@ const Chat: React.FC = ({ showChat, setShowChat }) => { }; useEffect(() => { - if (showChat) loadConversations(); + if (showChat) { + loadConversations(); + + const resizeObserver = new ResizeObserver(() => { + const target = chatContainerRef.current; + if (target) { + const bottom = target.scrollHeight - Math.round(target.scrollTop) === target.clientHeight; + setBottom(bottom); + } + }); + resizeObserver.observe(chatContainerRef.current); + return () => resizeObserver.disconnect(); // clean up + } }, [showChat]); return ( <> {showChat ? ( -
+
= ({ showChat, setShowChat }) => {
- +
+ + +
+ +
- - ))} - - + ))} + + + + + + ); }; diff --git a/frontend/src/pages/PatientManager/PatientSummary.tsx b/frontend/src/pages/PatientManager/PatientSummary.tsx index d7ceb878..5a32a3a9 100644 --- a/frontend/src/pages/PatientManager/PatientSummary.tsx +++ b/frontend/src/pages/PatientManager/PatientSummary.tsx @@ -3,7 +3,9 @@ import axios from "axios"; import { PatientInfo } from "./PatientTypes"; import Tooltip from "../../components/Tooltip"; import TypingAnimation from "../../components/Header/components/TypingAnimation.tsx"; -import { FaPencilAlt, FaPrint, FaMinus } from "react-icons/fa"; +import { FaPencilAlt, FaPrint, FaMinus, FaBug } from "react-icons/fa"; +import FeedbackForm from "../Feedback/FeedbackForm" +import Modal from "../../components/Modal/Modal"; interface PatientSummaryProps { showSummary: boolean; @@ -152,6 +154,18 @@ const PatientSummary = ({ null ); + const [isModalOpen, setIsModalOpen] = useState({status: false, id: ''}); + + const handleOpenModal = (id: string, event: React.MouseEvent) => { + event.stopPropagation(); + setIsModalOpen({status: true, id: id}); + }; + + const handleCloseModal = (event: React.MouseEvent) => { + event.stopPropagation(); + setIsModalOpen({status: false, id: ''}); + }; + useEffect(() => { if (isPatientDeleted) { setShowSummary(true); @@ -257,134 +271,148 @@ const PatientSummary = ({

{patientInfo.ID && ( -
- {!showSummary && ( -
-
-

- Patient Summary -

-
- - - -
-
-
- )} - {showSummary && ( -
-
+ <> +
+ {!showSummary && ( +
-

- Summary +

+ Patient Summary

- +
+ + + +
-
-

- {" "} - {patientInfo.ID} -

-

- Patient details and application -

-
-
-
-
-
-
- Current State: + )} + {showSummary && ( +
+
+
+

+ Summary +

+ +
+
+
+

+ {" "} + {patientInfo.ID} +

+

+ Patient details and application +

+
+
+
+
+
+
+ Current State: +
+
+ {patientInfo.Diagnosis} +
+
+
+
+
+ Risk Assessment:
-
- {patientInfo.Diagnosis} +
+
    + {/* Risk Assessment Items */} + {patientInfo.Psychotic === "Yes" && ( +
  • + Currently psychotic +
  • + )} + {patientInfo.Suicide === "Yes" && ( +
  • + + Patient has a history of suicide attempts + + info + + +
  • + )} + {/* Add other risk assessment items similarly */} +
-
-
-
- Risk Assessment: -
-
-
    - {/* Risk Assessment Items */} - {patientInfo.Psychotic === "Yes" && ( -
  • - Currently psychotic -
  • - )} - {patientInfo.Suicide === "Yes" && ( -
  • - - Patient has a history of suicide attempts - - info - - -
  • - )} - {/* Add other risk assessment items similarly */} -
-
-
-
-
-
- -
- {patientInfo.PriorMedications} -
+
+
+
+ +
+ {patientInfo.PriorMedications} +
+
-
- {renderMedicationsSection()} -
+ {renderMedicationsSection()} + +
-
- )} -
+ )} +
+ + + + )}