visuddhinanda 2 лет назад
Родитель
Сommit
40dc6ccc47
1 измененных файлов с 20 добавлено и 5 удалено
  1. 20 5
      dashboard/src/components/article/TypeArticleReader.tsx

+ 20 - 5
dashboard/src/components/article/TypeArticleReader.tsx

@@ -30,7 +30,6 @@ interface IWidget {
   hideInteractive?: boolean;
   hideTitle?: boolean;
   onArticleChange?: Function;
-  onFinal?: Function;
   onLoad?: Function;
   onAnthologySelect?: Function;
   onEdit?: Function;
@@ -44,7 +43,7 @@ const TypeArticleReaderWidget = ({
   active = false,
   hideInteractive = false,
   hideTitle = false,
-  onFinal,
+  onArticleChange,
   onLoad,
   onAnthologySelect,
   onEdit,
@@ -142,8 +141,10 @@ const TypeArticleReaderWidget = ({
 
   useEffect(() => {
     const url = `/v2/nav-article/${articleId}_${anthologyId}`;
+    console.info("api request", url);
     get<IArticleNavResponse>(url)
       .then((json) => {
+        console.debug("api response", json);
         if (json.ok) {
           setNav(json.data);
         }
@@ -162,9 +163,21 @@ const TypeArticleReaderWidget = ({
     };
   }
 
-  const title = articleData?.title_text
-    ? articleData?.title_text
-    : articleData?.title;
+  const title = articleData?.title_text ?? articleData?.title;
+
+  let endOfChapter = false;
+  if (nav?.curr && nav?.next) {
+    if (nav?.curr?.level > nav?.next?.level) {
+      endOfChapter = true;
+    }
+  }
+
+  let topOfChapter = false;
+  if (nav?.curr && nav?.prev) {
+    if (nav?.curr?.level > nav?.prev?.level) {
+      topOfChapter = true;
+    }
+  }
 
   return (
     <div>
@@ -234,6 +247,8 @@ const TypeArticleReaderWidget = ({
           <NavigateButton
             prevTitle={nav?.prev?.title}
             nextTitle={nav?.next?.title}
+            topOfChapter={topOfChapter}
+            endOfChapter={endOfChapter}
             path={currPath}
             onNext={() => {
               if (typeof onArticleChange !== "undefined") {