From 50b23dc8cf9691e471ca0373689092c014f5ff14 Mon Sep 17 00:00:00 2001 From: Tetiana Mohorian Date: Tue, 29 Apr 2025 22:45:04 +0000 Subject: [PATCH] Odstranit sk1/frontend/src/components/InfoBox.jsx --- sk1/frontend/src/components/InfoBox.jsx | 148 ------------------------ 1 file changed, 148 deletions(-) delete mode 100644 sk1/frontend/src/components/InfoBox.jsx diff --git a/sk1/frontend/src/components/InfoBox.jsx b/sk1/frontend/src/components/InfoBox.jsx deleted file mode 100644 index e47dd80..0000000 --- a/sk1/frontend/src/components/InfoBox.jsx +++ /dev/null @@ -1,148 +0,0 @@ -import React, { useState, useEffect } from 'react'; -import ChatInput from './ChatInput.jsx'; -import Historia from './Historia.jsx'; -import { ChevronDown, ChevronUp } from 'lucide-react'; - -const InfoBox = () => { - const [headerText, setHeaderText] = useState('Analyzujte text na nenávistný jazyk'); - const [paragraphText, setParagraphText] = useState('Tento nástroj využíva umelú inteligenciu na identifikáciu toxického obsahu v textoch. Stačí zadať text a zistiť, či obsahuje nenávistný jazyk.'); - const [history, setHistory] = useState([]); - const [showHistory, setShowHistory] = useState(false); - const [isLoading, setIsLoading] = useState(false); - - const fetchHistory = async () => { - try { - const response = await fetch("https://hate-backend-production.up.railway.app/api/history"); - const data = await response.json(); - setHistory(data.reverse()); - } catch (err) { - console.error("Nepodarilo sa načítať históriu:", err); - } - }; - - const handleSendMessage = async (userMessage) => { - setHeaderText("Analyzujem text..."); - setParagraphText("Analyzujeme váš text, prosím čakajte..."); - setIsLoading(true); - const startTime = Date.now(); - - try { - const response = await fetch("https://hate-backend-production.up.railway.app/api/predict", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ text: userMessage }), - }); - const data = await response.json(); - const elapsed = Date.now() - startTime; - const minimumDelay = 5000; - - if (elapsed < minimumDelay) { - await new Promise(resolve => setTimeout(resolve, minimumDelay - elapsed)); - } - - if (response.ok) { - setHeaderText(data.prediction); - setParagraphText(`Váš text bol: "${userMessage}"`); - fetchHistory(); - } else { - console.error("Server vrátil chybu:", data.error); - } - } catch (error) { - console.error("Chyba pri odosielaní:", error); - } finally { - setIsLoading(false); - } - }; - - useEffect(() => { - fetchHistory(); - }, []); - - - return ( -
-

{isLoading ? 'Analyzujem text...' : headerText}

-

{isLoading ? 'Prosím čakajte, prebieha analýza.' : paragraphText}

- -
- - - {isLoading && ( -
-
-
- )} - -
- - - {showHistory && ( -
-
-
- -
-
-
- )} -
-
-
- ); -}; - -export default InfoBox;