2
0
visuddhinanda 2 жил өмнө
parent
commit
563d8c8c28

+ 28 - 2
dashboard/src/components/fts/FtsBookList.tsx

@@ -29,8 +29,10 @@ interface IFtsItem {
 }
 }
 interface IWidget {
 interface IWidget {
   keyWord?: string;
   keyWord?: string;
+  keyWords?: string[];
+  engin?: "wbw" | "tulip";
   tags?: string[];
   tags?: string[];
-  bookId?: number;
+  bookId?: string | null;
   book?: number;
   book?: number;
   para?: number;
   para?: number;
   match?: string | null;
   match?: string | null;
@@ -41,6 +43,8 @@ interface IWidget {
 
 
 const FtsBookListWidget = ({
 const FtsBookListWidget = ({
   keyWord,
   keyWord,
+  keyWords,
+  engin = "wbw",
   tags,
   tags,
   bookId,
   bookId,
   book,
   book,
@@ -53,8 +57,24 @@ const FtsBookListWidget = ({
   const [ftsData, setFtsData] = useState<IFtsItem[]>();
   const [ftsData, setFtsData] = useState<IFtsItem[]>();
   const [total, setTotal] = useState<number>();
   const [total, setTotal] = useState<number>();
 
 
+  const focusBooks = bookId?.split(",");
+  console.log("focusBooks", focusBooks);
   useEffect(() => {
   useEffect(() => {
-    let url = `/v2/search-book-list?view=${view}&key=${keyWord}`;
+    let words;
+    let api = "";
+    switch (engin) {
+      case "wbw":
+        api = "search-pali-wbw-books";
+        words = keyWords?.join();
+        break;
+      case "tulip":
+        api = "search-book-list";
+        words = keyWord;
+        break;
+      default:
+        break;
+    }
+    let url = `/v2/${api}?view=${view}&key=${words}`;
     if (typeof tags !== "undefined") {
     if (typeof tags !== "undefined") {
       url += `&tags=${tags}`;
       url += `&tags=${tags}`;
     }
     }
@@ -64,6 +84,7 @@ const FtsBookListWidget = ({
     console.log("url", url);
     console.log("url", url);
     get<IFtsResponse>(url).then((json) => {
     get<IFtsResponse>(url).then((json) => {
       if (json.ok) {
       if (json.ok) {
+        console.log("data", json.data.rows);
         let totalResult = 0;
         let totalResult = 0;
         for (const iterator of json.data.rows) {
         for (const iterator of json.data.rows) {
           totalResult += iterator.count;
           totalResult += iterator.count;
@@ -95,9 +116,14 @@ const FtsBookListWidget = ({
         <List.Item>
         <List.Item>
           <div
           <div
             style={{
             style={{
+              padding: 4,
+              borderRadius: 4,
               display: "flex",
               display: "flex",
               justifyContent: "space-between",
               justifyContent: "space-between",
               cursor: "pointer",
               cursor: "pointer",
+              backgroundColor: focusBooks?.includes(item.pcdBookId.toString())
+                ? "lightblue"
+                : "unset",
             }}
             }}
             onClick={() => {
             onClick={() => {
               if (typeof onSelect !== "undefined") {
               if (typeof onSelect !== "undefined") {