visuddhinanda 2 лет назад
Родитель
Сommit
eb519b4435
1 измененных файлов с 7 добавлено и 12 удалено
  1. 7 12
      dashboard/src/components/template/SentEdit/SentTabCopy.tsx

+ 7 - 12
dashboard/src/components/template/SentEdit/SentTabCopy.tsx

@@ -1,4 +1,4 @@
-import { Dropdown, Tooltip } from "antd";
+import { Dropdown, Tooltip, notification } from "antd";
 import {
 import {
   CopyOutlined,
   CopyOutlined,
   ShoppingCartOutlined,
   ShoppingCartOutlined,
@@ -11,11 +11,8 @@ import store from "../../../store";
 import { modeChange } from "../../../reducers/cart-mode";
 import { modeChange } from "../../../reducers/cart-mode";
 import { useAppSelector } from "../../../hooks";
 import { useAppSelector } from "../../../hooks";
 import { mode as _mode } from "../../../reducers/cart-mode";
 import { mode as _mode } from "../../../reducers/cart-mode";
+import { addToCart } from "./SentCart";
 
 
-export interface ISentCart {
-  id: string;
-  text: string;
-}
 interface IWidget {
 interface IWidget {
   text?: string;
   text?: string;
   wbwData?: IWbw[];
   wbwData?: IWbw[];
@@ -50,17 +47,15 @@ const SentTabCopyWidget = ({ text, wbwData }: IWidget) => {
           setTimeout(() => setSuccess(false), 3000);
           setTimeout(() => setSuccess(false), 3000);
         });
         });
       } else {
       } else {
-        const oldText = localStorage.getItem("cart/text");
-        let cartText: ISentCart[] = [];
-        if (oldText) {
-          cartText = JSON.parse(oldText);
-        }
         const paliText = wbwData
         const paliText = wbwData
           ?.filter((value) => value.type?.value !== ".ctl.")
           ?.filter((value) => value.type?.value !== ".ctl.")
           .map((item) => item.word.value)
           .map((item) => item.word.value)
           .join(" ");
           .join(" ");
-        cartText.push({ id: text, text: paliText ? paliText : "" });
-        localStorage.setItem("cart/text", JSON.stringify(cartText));
+
+        addToCart([{ id: text, text: paliText ? paliText : "" }]);
+        notification.success({
+          message: "句子已经添加到Cart",
+        });
         setSuccess(true);
         setSuccess(true);
         setTimeout(() => setSuccess(false), 3000);
         setTimeout(() => setSuccess(false), 3000);
       }
       }