From 70e9d2d3566b9247aed5c76eb992e9f59d4cdd09 Mon Sep 17 00:00:00 2001 From: truskovskiyk Date: Wed, 25 Dec 2024 22:29:39 +0100 Subject: [PATCH] layout --- no-ocr-ui/src/components/Search.tsx | 30 +++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/no-ocr-ui/src/components/Search.tsx b/no-ocr-ui/src/components/Search.tsx index 3266492..1b0f94f 100644 --- a/no-ocr-ui/src/components/Search.tsx +++ b/no-ocr-ui/src/components/Search.tsx @@ -11,7 +11,9 @@ export default function Search() { const [answers, setAnswers] = useState<{ [key: number]: { is_answer: boolean, answer: string } }>({}); const [collections, setCollections] = useState([]); - + const [isModalOpen, setIsModalOpen] = useState(false); + const [modalImage, setModalImage] = useState(''); + useEffect(() => { async function fetchCollections() { try { @@ -32,8 +34,8 @@ export default function Search() { if (!selectedCollection || !searchQuery) return; setIsSearching(true); - setResults([]); // Clear old results - setAnswers({}); // Clear old answers + setResults([]); + setAnswers({}); try { const response = await fetch(`${noOcrApiUrl}/search`, { @@ -88,6 +90,16 @@ export default function Search() { } }; + const openModal = (imageBase64: string) => { + setModalImage(imageBase64); + setIsModalOpen(true); + }; + + const closeModal = () => { + setIsModalOpen(false); + setModalImage(''); + }; + return (

AI Search

@@ -151,7 +163,8 @@ export default function Search() { {`Page openModal(result.image_base64)} />
@@ -188,6 +201,15 @@ export default function Search() {
)} + + {isModalOpen && ( +
+
+ + Enlarged view +
+
+ )} ); }