visuddhinanda 3 лет назад
Родитель
Сommit
9f7f40e960
1 измененных файлов с 28 добавлено и 8 удалено
  1. 28 8
      dashboard/src/components/template/SentEdit/SentCell.tsx

+ 28 - 8
dashboard/src/components/template/SentEdit/SentCell.tsx

@@ -1,20 +1,36 @@
-import { useState } from "react";
+import { useEffect, useState } from "react";
 
 
 import { ISentence } from "../SentEdit";
 import { ISentence } from "../SentEdit";
 import SentEditMenu from "./SentEditMenu";
 import SentEditMenu from "./SentEditMenu";
 import SentCellEditable from "./SentCellEditable";
 import SentCellEditable from "./SentCellEditable";
 import MdView from "../MdView";
 import MdView from "../MdView";
-import SuggestionTabs from "./SuggestionTabs";
 import EditInfo from "./EditInfo";
 import EditInfo from "./EditInfo";
+import SuggestionToolbar from "./SuggestionToolbar";
+import { Divider } from "antd";
+import { useAppSelector } from "../../../hooks";
+import { sentence } from "../../../reducers/accept-pr";
 
 
 interface ISentCell {
 interface ISentCell {
   data: ISentence;
   data: ISentence;
   wordWidget?: boolean;
   wordWidget?: boolean;
+  isPr?: boolean;
 }
 }
-const Widget = ({ data, wordWidget = false }: ISentCell) => {
+const Widget = ({ data, wordWidget = false, isPr = false }: ISentCell) => {
   const [isEditMode, setIsEditMode] = useState(false);
   const [isEditMode, setIsEditMode] = useState(false);
   const [sentData, setSentData] = useState<ISentence>(data);
   const [sentData, setSentData] = useState<ISentence>(data);
-
+  const acceptPr = useAppSelector(sentence);
+  useEffect(() => {
+    if (typeof acceptPr !== "undefined" && !isPr) {
+      if (
+        acceptPr.book === data.book &&
+        acceptPr.para === data.para &&
+        acceptPr.wordStart === data.wordStart &&
+        acceptPr.wordEnd === data.wordEnd &&
+        acceptPr.channel.id === data.channel.id
+      )
+        setSentData(acceptPr);
+    }
+  }, [acceptPr, data, isPr]);
   return (
   return (
     <div style={{ marginBottom: "8px" }}>
     <div style={{ marginBottom: "8px" }}>
       <SentEditMenu
       <SentEditMenu
@@ -24,8 +40,10 @@ const Widget = ({ data, wordWidget = false }: ISentCell) => {
           }
           }
         }}
         }}
       >
       >
-        <EditInfo data={data} />
-        <div style={{ display: isEditMode ? "none" : "block" }}>
+        <EditInfo data={sentData} />
+        <div
+          style={{ display: isEditMode ? "none" : "block", marginLeft: "2em" }}
+        >
           <MdView
           <MdView
             html={sentData.html !== "" ? sentData.html : "请输入"}
             html={sentData.html !== "" ? sentData.html : "请输入"}
             wordWidget={wordWidget}
             wordWidget={wordWidget}
@@ -34,6 +52,7 @@ const Widget = ({ data, wordWidget = false }: ISentCell) => {
         <div style={{ display: isEditMode ? "block" : "none" }}>
         <div style={{ display: isEditMode ? "block" : "none" }}>
           <SentCellEditable
           <SentCellEditable
             data={sentData}
             data={sentData}
+            isPr={isPr}
             onClose={() => {
             onClose={() => {
               setIsEditMode(false);
               setIsEditMode(false);
             }}
             }}
@@ -43,10 +62,11 @@ const Widget = ({ data, wordWidget = false }: ISentCell) => {
           />
           />
         </div>
         </div>
 
 
-        <div>
-          <SuggestionTabs data={data} />
+        <div style={{ marginLeft: "2em" }}>
+          <SuggestionToolbar data={data} isPr={isPr} />
         </div>
         </div>
       </SentEditMenu>
       </SentEditMenu>
+      <Divider style={{ margin: "10px 0" }} />
     </div>
     </div>
   );
   );
 };
 };