summaryrefslogtreecommitdiff
path: root/src/actions/deck.ts
blob: e501f23692e042addd1b1416729bf01e390e1cc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"use server";
import ServerWord from "@/zoom/ServerWord";
import { analyzeTHWord, segmentateThai } from "@/pages/api/nlp";
import db from "../lib/db";

export function shuffleDeck(userId: number, lessonId: number) {
  const res = db.fetchLesson({ userId, lessonId, random: true });
  return res;
}

export async function thaiAnalysis(text: string) {
  const res = await segmentateThai(text);
  const res2 = await analyzeTHWord(text);
  console.log({ res, res2 });
}
export async function toggleBookmark(
  userId: number,
  wordId: number,
  is: boolean,
  notes?: string,
) {
  console.log("toggling on server, ostensibly");
  const r = !is
    ? db.addBookmark(userId, wordId, notes)
    : db.delBookmark(userId, wordId);
  return { ok: "ack" };
}

// export async function ocrAction(file: File): AsyncRes<string[]> {
//   const res = await NLP.ocr(file);
//   return res;
// }