From fd86dc15734f3b7126d88f0130897c597100e30a Mon Sep 17 00:00:00 2001 From: polwex Date: Thu, 15 May 2025 20:32:25 +0700 Subject: m --- src/components/Main.tsx | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/components/Main.tsx') diff --git a/src/components/Main.tsx b/src/components/Main.tsx index 2157a91..3e6f3e7 100644 --- a/src/components/Main.tsx +++ b/src/components/Main.tsx @@ -19,6 +19,7 @@ import { CardTitle, } from "@/components/ui/card"; import { Loader2 } from "lucide-react"; // Loading spinner +import { useRouter } from "waku"; const SorlangPage: React.FC = () => { const [textValue, setTextValue] = useState(""); @@ -82,24 +83,30 @@ const SorlangPage: React.FC = () => { }; }, [handlePaste]); - const handleProcessText = async () => { - setIsAnalyzing(true); - const text = textValue.trim(); - if (!text) { - alert("Text area is empty!"); - return; - } + const router = useRouter(); + async function fetchNLP(text: string, app: "spacy" | "stanza") { const opts = { method: "POST", headers: { "Content-type": "application/json" }, - body: JSON.stringify({ text, app: "spacy" }), + body: JSON.stringify({ text, app }), }; const res = await fetch("/api/nlp", opts); const j = await res.json(); console.log("j", j); if ("ok" in j) { - console.log("good"); + sessionStorage.setItem(`${app}res`, JSON.stringify(j.ok)); + } + } + + const handleProcessText = async () => { + setIsAnalyzing(true); + const text = textValue.trim(); + if (!text) { + alert("Text area is empty!"); + return; } + await Promise.all([fetchNLP(text, "spacy"), fetchNLP(text, "stanza")]); + router.push("/zoom"); setIsAnalyzing(false); }; -- cgit v1.2.3