summaryrefslogtreecommitdiff
path: root/src/components/Main.tsx
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-05-15 20:32:25 +0700
committerpolwex <polwex@sortug.com>2025-05-15 20:32:25 +0700
commitfd86dc15734f3b7126d88f0130897c597100e30a (patch)
tree253890a5f0bde7bc460904ce1743581f53a23d5b /src/components/Main.tsx
parent3d4b740e5a512db8fbdd934af2fbc9585fa00f0f (diff)
m
Diffstat (limited to 'src/components/Main.tsx')
-rw-r--r--src/components/Main.tsx25
1 files changed, 16 insertions, 9 deletions
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<string>("");
@@ -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);
};