From 60897022b3edb9d8ef39fd200cd64b872bd21d6e Mon Sep 17 00:00:00 2001 From: Kanav Chopra <72208392+code-kanav@users.noreply.github.com> Date: Wed, 23 Jul 2025 14:18:36 -0700 Subject: [PATCH 1/7] ui fixes --- package-lock.json | 4 +- src/components/consultPage.tsx | 476 ++++++++++++++++++++++----------- src/components/searchBar.tsx | 5 +- 3 files changed, 319 insertions(+), 166 deletions(-) diff --git a/package-lock.json b/package-lock.json index 349da01..131fd5f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "my-app", + "name": "sage-frontend", "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "my-app", + "name": "sage-frontend", "version": "0.1.0", "dependencies": { "@emotion/cache": "^11.14.0", diff --git a/src/components/consultPage.tsx b/src/components/consultPage.tsx index dea42ac..fe6fdd0 100644 --- a/src/components/consultPage.tsx +++ b/src/components/consultPage.tsx @@ -346,13 +346,13 @@ const scrollToBottom = () => { if (Array.isArray(data)) { // Render array as a nested List return ( - + {data.map((item, index) => ( {renderKeyValuePairs(item, level + 1)} {/* Add separator between array items */} {index < data.length - 1 && ( - + )} ))} @@ -372,7 +372,10 @@ const scrollToBottom = () => { opacity: 0, transform: "translateY(10px)", animation: `fadeIn 0.5s ease-in ${index * 0.2}s forwards`, - pl: level, + pl: level - 1, + pr: 0, + m: 0, + width: "100%", "@keyframes fadeIn": { from: { opacity: 0, transform: "translateY(10px)" }, @@ -391,13 +394,14 @@ const scrollToBottom = () => { component="p" sx={{ pl: 0, + pr: 0, color: "grey.700", - paddingLeft: 0, display: "flex", flexDirection: "column", listStyleType: "none", gap: "0.5rem", width: "100%", + m: 0, }} > {children} @@ -427,7 +431,7 @@ const scrollToBottom = () => { ) : Array.isArray(value) || (typeof value === "object" && value !== null) ? ( // Render nested object/array as a nested List - + {renderKeyValuePairs(value, level + 1)} ) : ( @@ -438,7 +442,7 @@ const scrollToBottom = () => { {/* Add separator after each key except the last */} {index < entries.length - 1 && ( - + )} ))} @@ -452,6 +456,8 @@ const scrollToBottom = () => { flexDirection: "column", alignItems: "flex-start", pl: 0, + pr: 0, + m: 0, width: "100%", }} > @@ -481,124 +487,280 @@ const scrollToBottom = () => { paddingTop: "0px", }} > - + {response ? ( <> - - - Patient Information - - - - {displayedTemplate.map((item, index) => ( - - - - {item.field}: - - {typeof item.value === "string" && - item.value.includes("\n") ? ( - ( - - {children} - - ), - p: ({ children }) => ( - - {children} - - ), + + + Patient Information + + + + {displayedTemplate.length > 1 ? ( + <> + {/* First two items on one line */} + + {displayedTemplate.slice(0, 2).map((item, index) => ( + - {item.value} - - ) : ( - ( - - {children} - - ), + + {item.field}: + + {typeof item.value === "string" && item.value.includes("\n") ? ( + ( + + {children} + + ), + p: ({ children }) => ( + + {children} + + ), + }} + > + {item.value} + + ) : ( + ( + + {children} + + ), + }} + > + {item.value || "N/A"} + + )} + + ))} + + {/* Rest of the items, one per line */} + {displayedTemplate.slice(2).map((item, index) => ( + + - {item.value || "N/A"} - - )} - - {index <= displayedTemplate.length - 1 && ( - - )}{" "} - - ))} - - Template Information - + + {item.field}: + + {typeof item.value === "string" && item.value.includes("\n") ? ( + ( + + {children} + + ), + p: ({ children }) => ( + + {children} + + ), + }} + > + {item.value} + + ) : ( + ( + + {children} + + ), + }} + > + {item.value || "N/A"} + + )} + + + ))} + + ) : ( + // If only one item, render as before + displayedTemplate.map((item, index) => ( + + + + {item.field}: + + {typeof item.value === "string" && item.value.includes("\n") ? ( + ( + + {children} + + ), + p: ({ children }) => ( + + {children} + + ), + }} + > + {item.value} + + ) : ( + ( + + {children} + + ), + }} + > + {item.value || "N/A"} + + )} + + + )) + )} + + + + Template Information + + {response?.populatedTemplate && response.populatedTemplate.length > 0 ? response.populatedTemplate.map((item, index) => ( - - - {renderKeyValuePairs(item as KeyValueObject)} - + + {renderKeyValuePairs(item as KeyValueObject, 0)} {index < response.populatedTemplate.length - 1 && ( - + )} - + )) : null} - ) : ( @@ -606,31 +768,34 @@ const scrollToBottom = () => { Loading... {[...Array(1)].map((_, index) => ( - + {currentPhaseContent.heading} {(showPhase1 || showPhase2 || showPhase3) && ( - + {currentPhaseContent.steps .slice(0, step) .map((stepText, index) => ( - + {stepText} ))} )} - - + + ))} @@ -917,41 +1082,30 @@ const scrollToBottom = () => { )} {response.specialistAIResponse.citations.map( (citation, index) => citation.name ? ( // Ensure citation.name is not undefined or null - - - - - + + ) : null // Skip rendering if citation.name is invalid )} @@ -1099,34 +1253,32 @@ const scrollToBottom = () => { > {msg.text.citations.map( (citation, citationIndex) => ( - - - - - + + ) )} diff --git a/src/components/searchBar.tsx b/src/components/searchBar.tsx index 35f3b0b..113cde7 100644 --- a/src/components/searchBar.tsx +++ b/src/components/searchBar.tsx @@ -17,7 +17,7 @@ import ListIcon from '@mui/icons-material/List'; import SearchIcon from '@mui/icons-material/Search'; import PlayCircleFilledWhiteIcon from '@mui/icons-material/PlayCircleFilledWhite'; import { styled } from '@mui/material/styles'; -; +import { ChevronRight } from '@mui/icons-material'; const StyledInputBase = styled(InputBase)(({ theme }) => ({ @@ -241,8 +241,9 @@ export function FollowUpQuestions({ )) : suggestions.map((question, index) => ( - onSuggestionClick(question)}> + onSuggestionClick(question)} sx={{ justifyContent: 'space-between', gap:"10px", alignItems: "flex-start" , '&:hover': { opacity: 0.7, backgroundColor: "white"} }}> + {/* Orange arrow */} {index < suggestions.length - 1 && } From 1467885bb2ec39a1129c6b394fad63c0ac4714ad Mon Sep 17 00:00:00 2001 From: Kanav Chopra <72208392+code-kanav@users.noreply.github.com> Date: Fri, 25 Jul 2025 13:59:10 -0700 Subject: [PATCH 2/7] made the left side editable --- package-lock.json | 15 + package.json | 2 + src/components/consultPage.tsx | 1006 ++++++++++++++++++++------------ 3 files changed, 649 insertions(+), 374 deletions(-) diff --git a/package-lock.json b/package-lock.json index 131fd5f..33836ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@mui/material-nextjs": "^6.4.2", "@mui/styles": "^6.4.3", "@server-sent-stream/web": "^1.0.3", + "file-saver": "^2.0.5", "next": "^15.1.6", "react": "^19.0.0", "react-cookie": "^8.0.1", @@ -26,6 +27,7 @@ }, "devDependencies": { "@eslint/eslintrc": "^3", + "@types/file-saver": "^2.0.7", "@types/node": "^20.3.0", "@types/react": "^19.0.8", "@types/react-dom": "^19", @@ -1608,6 +1610,13 @@ "@types/estree": "*" } }, + "node_modules/@types/file-saver": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/file-saver/-/file-saver-2.0.7.tgz", + "integrity": "sha512-dNKVfHd/jk0SkR/exKGj2ggkB45MAkzvWCaqLUUgkyjITkGNzH8H+yUwr+BLJUBjZOe9w8X3wgmXhZDRg1ED6A==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/hast": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", @@ -3703,6 +3712,12 @@ "node": ">=16.0.0" } }, + "node_modules/file-saver": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz", + "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==", + "license": "MIT" + }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", diff --git a/package.json b/package.json index 0118760..62972c0 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@mui/material-nextjs": "^6.4.2", "@mui/styles": "^6.4.3", "@server-sent-stream/web": "^1.0.3", + "file-saver": "^2.0.5", "next": "^15.1.6", "react": "^19.0.0", "react-cookie": "^8.0.1", @@ -27,6 +28,7 @@ }, "devDependencies": { "@eslint/eslintrc": "^3", + "@types/file-saver": "^2.0.7", "@types/node": "^20.3.0", "@types/react": "^19.0.8", "@types/react-dom": "^19", diff --git a/src/components/consultPage.tsx b/src/components/consultPage.tsx index fe6fdd0..53b3a16 100644 --- a/src/components/consultPage.tsx +++ b/src/components/consultPage.tsx @@ -14,7 +14,6 @@ import { IconButton, Tooltip, } from "@mui/material"; -import Link from "next/link"; import ReactMarkdown from "react-markdown"; import Divider from "@mui/material/Divider"; import { FollowUpQuestions, SearchBar } from "./searchBar"; @@ -22,7 +21,7 @@ import ContentCopyIcon from "@mui/icons-material/ContentCopy"; import { useMemo } from "react"; // Ensure useMemo is imported import ArrowDownwardIcon from "@mui/icons-material/ArrowDownward"; import EditNoteRoundedIcon from "@mui/icons-material/EditNoteRounded"; - +import DownloadIcon from "@mui/icons-material/Download"; interface ApiResponse { specialistSummary: string; basicPatientSummary: Array<{ @@ -161,11 +160,6 @@ const scrollToBottom = () => { return () => clearTimeout(timer); }, [phase, step]); - useEffect(() => { - if (response?.basicPatientSummary) { - setDisplayedTemplate(response.basicPatientSummary); - } - }, [response?.basicPatientSummary]); // Typing summaryResponse word-by-word useEffect(() => { @@ -339,30 +333,122 @@ const scrollToBottom = () => { [key: string]: KeyValueData; } - const renderKeyValuePairs = ( - data: KeyValueData, - level: number = 0 - ): React.ReactNode => { - if (Array.isArray(data)) { - // Render array as a nested List - return ( - - {data.map((item, index) => ( - - {renderKeyValuePairs(item, level + 1)} - {/* Add separator between array items */} - {index < data.length - 1 && ( - - )} - - ))} - - ); - } else if (typeof data === "object" && data !== null) { - const entries = Object.entries(data as KeyValueObject); - return ( - <> - {entries.map(([key, value], index) => ( + type JSONPrimitive = string | number | boolean | null; +type JSONValue = JSONPrimitive | JSONObject | JSONArray; + +interface JSONObject { + [key: string]: JSONValue; +} + +type JSONArray = JSONValue[]; + +const [isEditingLeft, setIsEditingLeft] = useState(false); + +const [editableTemplate, setEditableTemplate] = useState>([]); + +const [editablePopulatedTemplate, setEditablePopulatedTemplate] = useState([]); +const [displayedPopulatedTemplate, setDisplayedPopulatedTemplate] = useState([]); + +useEffect(() => { + if (response?.basicPatientSummary) { + setDisplayedTemplate(response.basicPatientSummary); + setEditableTemplate(response.basicPatientSummary.map(item => ({ ...item }))); + } + if (response?.populatedTemplate) { + setDisplayedPopulatedTemplate(response.populatedTemplate.map(item => ({ ...item })) as JSONValue[]); + setEditablePopulatedTemplate(response.populatedTemplate.map(item => ({ ...item })) as JSONValue[]); + } +}, [response?.basicPatientSummary, response?.populatedTemplate]); + +const handleEditLeft = () => setIsEditingLeft(true); +const handleCancelLeft = () => { + setEditableTemplate(displayedTemplate.map(item => ({ ...item }))); + setEditablePopulatedTemplate( + displayedPopulatedTemplate.map(item => + typeof item === "object" && item !== null && !Array.isArray(item) + ? { ...item } + : item + ) + ); + setIsEditingLeft(false); +}; +const handleSaveLeft = () => { + setDisplayedTemplate(editableTemplate.map(item => ({ ...item }))); + setDisplayedPopulatedTemplate( + editablePopulatedTemplate.map(item => + typeof item === "object" && item !== null && !Array.isArray(item) + ? { ...item } + : item + ) + ); + setIsEditingLeft(false); +}; + +function updateNestedValue( + obj: JSONObject | JSONArray, + path: (string | number)[], + value: JSONValue +): void { + if (path.length === 0) return; + + const [first, ...rest] = path; + + if (rest.length === 0) { + if (Array.isArray(obj) && typeof first === "number") { + obj[first] = value; + } else if (!Array.isArray(obj) && typeof first === "string") { + obj[first] = value; + } + return; + } + + const next = + Array.isArray(obj) && typeof first === "number" + ? obj[first] + : !Array.isArray(obj) && typeof first === "string" + ? obj[first] + : undefined; + + if ( + typeof next === "object" && + next !== null && + (Array.isArray(next) || typeof next === "object") + ) { + updateNestedValue(next as JSONObject | JSONArray, rest, value); + } +} + + +const renderKeyValuePairs = ( + data: JSONValue, + path: (string | number)[] = [], + isEditing: boolean = false, + setEditable?: (updater: (prev: JSONValue[]) => JSONValue[]) => void +): React.ReactNode => { + if (Array.isArray(data)) { + return ( + + {data.map((item, index) => ( + + {renderKeyValuePairs(item, [...path, index], isEditing, setEditable)} + {index < data.length - 1 && ( + + )} + + ))} + + ); + } + + if (typeof data === "object" && data !== null) { + const entries = Object.entries(data); + + return ( + <> + {entries.map(([key, value], index) => { + const currentPath = [...path, key]; + + return ( { opacity: 0, transform: "translateY(10px)", animation: `fadeIn 0.5s ease-in ${index * 0.2}s forwards`, - pl: level - 1, + pl: path.length, pr: 0, m: 0, - width: "100%", "@keyframes fadeIn": { from: { opacity: 0, transform: "translateY(10px)" }, @@ -386,7 +471,32 @@ const scrollToBottom = () => { {key}: - {typeof value === "string" && value.includes("\n") ? ( + + {isEditing && (typeof value === "string" || typeof value === "number" || typeof value === "boolean") ? ( + { + const newValue: JSONValue = typeof value === "number" + ? Number(e.target.value) + : typeof value === "boolean" + ? e.target.value === "true" + : e.target.value; + + if (setEditable) { + setEditable(prev => { + const updated = JSON.parse(JSON.stringify(prev)) as JSONValue[]; + updateNestedValue(updated, currentPath, newValue); + return updated; + }); + } + }} + sx={{ mt: 1, mb: 1 }} + /> + ) : typeof value === "string" && value.includes("\n") ? ( ( @@ -428,11 +538,9 @@ const scrollToBottom = () => { > {value || "N/A"} - ) : Array.isArray(value) || - (typeof value === "object" && value !== null) ? ( - // Render nested object/array as a nested List + ) : Array.isArray(value) || typeof value === "object" ? ( - {renderKeyValuePairs(value, level + 1)} + {renderKeyValuePairs(value, currentPath, isEditing, setEditable)} ) : ( @@ -440,35 +548,73 @@ const scrollToBottom = () => { )} - {/* Add separator after each key except the last */} {index < entries.length - 1 && ( )} - ))} - - ); - } else { - return ( - - - {String(data)} - - - ); - } + ); + })} + + ); + } + + return ( + + + {String(data)} + + + ); +}; + + +const handleDownload = () => { + const leftContent = document.getElementById('left-panel')?.innerHTML || ''; + const rightContent = document.getElementById('right-panel')?.innerHTML || ''; + const combinedContent = ` +

Exported Content

+

Left Panel

+ ${leftContent} +

Right Panel

+ ${rightContent} + `; + exportToWord(combinedContent); }; + function exportToWord(combinedContent: string) { + // Create a complete HTML document for Word + const html = + `` + + `Exported Content${combinedContent}`; + + // Create a Blob with the correct MIME type for Word + const blob = new Blob(['\ufeff', html], { + type: 'application/msword', + }); + + // Create a download link and trigger it + const url = URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = url; + link.download = 'exported-content.doc'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + URL.revokeObjectURL(url); +} + return ( { }} > {/* Left Side (Lab Data & History) */} - - - {response ? ( - <> - - - - Patient Information - + + + + {response ? ( + <> + + + + Patient Information + + {!isEditingLeft && ( + <> + + + + + + {/* Download Button */} + + + + + + + )} + {isEditingLeft && ( + + + + + )} + + + + {(isEditingLeft ? editableTemplate : displayedTemplate).length > 1 ? ( + <> + {/* First two items on one line */} + + {(isEditingLeft ? editableTemplate : displayedTemplate).slice(0, 2).map((item, index) => ( + + + {item.field}: + + {isEditingLeft ? ( + { + const newValue = e.target.value; + setEditableTemplate(prev => { + const updated = [...prev]; + updated[index] = { ...updated[index], value: newValue }; + return updated; + }); + }} + sx={{ mt: 1, mb: 1 }} + /> + ) : ( + typeof item.value === "string" && item.value.includes("\n") ? ( + ( + + {children} + + ), + p: ({ children }) => ( + + {children} + + ), + }} + > + {item.value} + + ) : ( + ( + + {children} + + ), + }} + > + {item.value || "N/A"} + + ) + )} + + ))} - - {displayedTemplate.length > 1 ? ( - <> - {/* First two items on one line */} - - {displayedTemplate.slice(0, 2).map((item, index) => ( - ( + + + + {item.field}: + + {isEditingLeft ? ( + { + const newValue = e.target.value; + setEditableTemplate(prev => { + const updated = [...prev]; + updated[index + 2] = { ...updated[index + 2], value: newValue }; + return updated; + }); + }} + sx={{ mt: 1, mb: 1 }} + /> + ) : ( + typeof item.value === "string" && item.value.includes("\n") ? ( + ( + + {children} + + ), + p: ({ children }) => ( + + {children} + + ), }} > - - {item.field}: - - {typeof item.value === "string" && item.value.includes("\n") ? ( - ( - - {children} - - ), - p: ({ children }) => ( - - {children} - - ), - }} - > - {item.value} - - ) : ( - ( - - {children} - - ), - }} - > - {item.value || "N/A"} - - )} - - ))} - - {/* Rest of the items, one per line */} - {displayedTemplate.slice(2).map((item, index) => ( - - + ) : ( + ( + + {children} + + ), }} > - - {item.field}: - - {typeof item.value === "string" && item.value.includes("\n") ? ( - ( - - {children} - - ), - p: ({ children }) => ( - - {children} - - ), + {item.value || "N/A"} + + ) + )} + + + ))} + + ) : ( + // If only one item, render as before + (isEditingLeft ? editableTemplate : displayedTemplate).map((item, index) => ( + + + + {item.field}: + + {isEditingLeft ? ( + { + const newValue = e.target.value; + setEditableTemplate(prev => { + const updated = [...prev]; + updated[index] = { ...updated[index], value: newValue }; + return updated; + }); + }} + sx={{ mt: 1, mb: 1 }} + /> + ) : ( + typeof item.value === "string" && item.value.includes("\n") ? ( + ( + - {item.value} - - ) : ( - ( - - {children} - - ), - }} + {children} + + ), + p: ({ children }) => ( + + {children} + + ), + }} + > + {item.value} + + ) : ( + ( + - {item.value || "N/A"} - - )} - - - ))} - - ) : ( - // If only one item, render as before - displayedTemplate.map((item, index) => ( - - + ), }} > - - {item.field}: - - {typeof item.value === "string" && item.value.includes("\n") ? ( - ( - - {children} - - ), - p: ({ children }) => ( - - {children} - - ), - }} - > - {item.value} - - ) : ( - ( - - {children} - - ), - }} - > - {item.value || "N/A"} - - )} - - - )) - )} - - - - Template Information - - - {response?.populatedTemplate && - response.populatedTemplate.length > 0 - ? response.populatedTemplate.map((item, index) => ( - - {renderKeyValuePairs(item as KeyValueObject, 0)} - {index < response.populatedTemplate.length - 1 && ( - - )} - - )) - : null} - - - ) : ( - <> - - Loading... - - {[...Array(1)].map((_, index) => ( - - - {currentPhaseContent.heading} - - {(showPhase1 || showPhase2 || showPhase3) && ( - - {currentPhaseContent.steps - .slice(0, step) - .map((stepText, index) => ( - - {stepText} - - ))} - - )} - - + {item.value || "N/A"} + + ) + )} + - ))} - - )} - - + )) + )} + + + + Template Information + + +{isEditingLeft + ? editablePopulatedTemplate.map((item, idx) => ( + + {renderKeyValuePairs(item, [idx], true, setEditablePopulatedTemplate)} + {idx < editablePopulatedTemplate.length - 1 && } + + )) + : displayedPopulatedTemplate.map((item, idx) => ( + + {renderKeyValuePairs(item, [idx])} + {idx < displayedPopulatedTemplate.length - 1 && } + + ))} + + + ) : ( + // ...loading state as before... + <> + + Loading... + + {[...Array(1)].map((_, index) => ( + + + {currentPhaseContent.heading} + + {(showPhase1 || showPhase2 || showPhase3) && ( + + {currentPhaseContent.steps + .slice(0, step) + .map((stepText, index) => ( + + {stepText} + + ))} + + )} + + + + ))} + + )} + + {/* Right Side (AI-Generated Response) */} { }; export default ConsultPage; + + + From dd7dc84849dea142fad3538942fa18c3dd8e8bc3 Mon Sep 17 00:00:00 2001 From: Kanav Chopra <72208392+code-kanav@users.noreply.github.com> Date: Fri, 25 Jul 2025 14:59:40 -0700 Subject: [PATCH 3/7] ui fix --- src/components/clinicalQuestionPage.tsx | 8 +++++--- src/components/footer.tsx | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/clinicalQuestionPage.tsx b/src/components/clinicalQuestionPage.tsx index 99a53c5..747f319 100644 --- a/src/components/clinicalQuestionPage.tsx +++ b/src/components/clinicalQuestionPage.tsx @@ -61,7 +61,8 @@ export default function ClinicalQuestionPage({ @@ -72,11 +73,12 @@ export default function ClinicalQuestionPage({ What are your clinical notes? - + diff --git a/src/components/footer.tsx b/src/components/footer.tsx index 3d30788..c230784 100644 --- a/src/components/footer.tsx +++ b/src/components/footer.tsx @@ -12,7 +12,7 @@ export default function Footer() { left: 0, width: "100%", backgroundColor: "#182635", - padding: "20px", + padding: "16px", textAlign: "center", color: "white", }} From 54c2f646f5f56818bba32bc964e2dc7800052dc1 Mon Sep 17 00:00:00 2001 From: Kanav Chopra <72208392+code-kanav@users.noreply.github.com> Date: Wed, 6 Aug 2025 15:08:37 -0500 Subject: [PATCH 4/7] fixed height of text box --- src/components/clinicalQuestionPage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/clinicalQuestionPage.tsx b/src/components/clinicalQuestionPage.tsx index 747f319..0bd940e 100644 --- a/src/components/clinicalQuestionPage.tsx +++ b/src/components/clinicalQuestionPage.tsx @@ -62,7 +62,7 @@ export default function ClinicalQuestionPage({ label="Enter your clinical question" multiline minRows={3} - maxRows={6} + maxRows={7} onChange={handleQuestionChange} error={!!questionError} /> @@ -77,8 +77,8 @@ export default function ClinicalQuestionPage({ From e4c1f7b74e206b635f07ebb6a458cbb7c1976951 Mon Sep 17 00:00:00 2001 From: Kanav Chopra <72208392+code-kanav@users.noreply.github.com> Date: Fri, 3 Oct 2025 17:09:18 -0500 Subject: [PATCH 5/7] added new end point --- src/components/searchBar.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/searchBar.tsx b/src/components/searchBar.tsx index 113cde7..45cdca1 100644 --- a/src/components/searchBar.tsx +++ b/src/components/searchBar.tsx @@ -68,7 +68,7 @@ export function SearchBar({ ]); try { - const response = await fetch(process.env.NEXT_PUBLIC_BACKEND_URL + '/ask-pathway-streamed', { + const response = await fetch(process.env.NEXT_PUBLIC_BACKEND_URL + '/ask-specialist-streamed', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ question: searchTerm }), @@ -203,6 +203,8 @@ export function FollowUpQuestions({ } }, [barLoading]); + console.log("suggestions",suggestions) + return ( Date: Fri, 3 Oct 2025 17:18:10 -0500 Subject: [PATCH 6/7] added new end point --- src/components/searchBar.tsx | 48 +++++++++++++++++------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/components/searchBar.tsx b/src/components/searchBar.tsx index 45cdca1..0b9c548 100644 --- a/src/components/searchBar.tsx +++ b/src/components/searchBar.tsx @@ -33,11 +33,6 @@ const StyledInputBase = styled(InputBase)(({ theme }) => ({ })); -// interface SearchBarProps { -// barLoading: boolean; -// setBotReply: React.Dispatch } }[]>>; -// } - export function SearchBar({ searchTerm, setSearchTerm, @@ -174,28 +169,31 @@ export function FollowUpQuestions({ const [suggestionsLoading, setSuggestionsLoading] = useState(true); const [suggestions, setSuggestions] = useState([]); - const fetchSuggestions = async () => { - setSuggestionsLoading(true); - try { - const response = await fetch(process.env.NEXT_PUBLIC_BACKEND_URL + '/followup-questions', { - credentials: 'include', - }); +const fetchSuggestions = async () => { + setSuggestionsLoading(true); + try { + const response = await fetch(process.env.NEXT_PUBLIC_BACKEND_URL + '/followup-questions', { + credentials: 'include', + }); - if (!response.ok) { - throw new Error('Failed to fetch suggestions'); - } - const result = await response.json(); - if (Array.isArray(result)) { - setSuggestions(result); - } else { - console.warn('Unexpected response format:', result); - } - } catch (error) { - console.error('Error fetching suggestions:', error); - } finally { - setSuggestionsLoading(false); + if (!response.ok) { + throw new Error('Failed to fetch suggestions'); } - }; + const result = await response.json(); + // Fix: Use result.questions if available + if (Array.isArray(result.questions)) { + setSuggestions(result.questions); + } else if (Array.isArray(result)) { + setSuggestions(result); + } else { + console.warn('Unexpected response format:', result); + } + } catch (error) { + console.error('Error fetching suggestions:', error); + } finally { + setSuggestionsLoading(false); + } +}; useEffect(() => { if (!barLoading) { From 81950fa8752d474559d0cfdcc96cb7d09c4e5f4e Mon Sep 17 00:00:00 2001 From: Kanav Chopra <72208392+code-kanav@users.noreply.github.com> Date: Fri, 3 Oct 2025 17:22:54 -0500 Subject: [PATCH 7/7] removed console --- src/components/searchBar.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/searchBar.tsx b/src/components/searchBar.tsx index 0b9c548..00bbaac 100644 --- a/src/components/searchBar.tsx +++ b/src/components/searchBar.tsx @@ -201,7 +201,6 @@ const fetchSuggestions = async () => { } }, [barLoading]); - console.log("suggestions",suggestions) return (