visuddhinanda 2 лет назад
Родитель
Сommit
f2dea67300
1 измененных файлов с 19 добавлено и 5 удалено
  1. 19 5
      dashboard/src/components/template/Wbw/WbwVideoButton.tsx

+ 19 - 5
dashboard/src/components/template/Wbw/WbwVideoButton.tsx

@@ -1,7 +1,11 @@
 import { VideoCameraOutlined } from "@ant-design/icons";
 import { VideoCameraOutlined } from "@ant-design/icons";
+import { useEffect, useState } from "react";
+import { get } from "../../../request";
+import { IAttachmentResponse } from "../../api/Attachments";
 import VideoModal from "../../general/VideoModal";
 import VideoModal from "../../general/VideoModal";
 
 
 export interface IVideo {
 export interface IVideo {
+  videoId: string;
   url?: string;
   url?: string;
   type?: string;
   type?: string;
   title?: string;
   title?: string;
@@ -10,13 +14,23 @@ interface IWidget {
   video: IVideo[];
   video: IVideo[];
 }
 }
 const WbwVideoButtonWidget = ({ video }: IWidget) => {
 const WbwVideoButtonWidget = ({ video }: IWidget) => {
-  const url = video ? video[0].url : "";
-  const src: string = process.env.REACT_APP_WEB_HOST
-    ? process.env.REACT_APP_WEB_HOST
-    : "";
+  const [url, setUrl] = useState<string>();
+  const [curr, setCurr] = useState(0);
+
+  useEffect(() => {
+    get<IAttachmentResponse>(`/v2/attachment/${video[curr].videoId}`).then(
+      (json) => {
+        console.log(json);
+        if (json.ok) {
+          setUrl(json.data.url);
+        }
+      }
+    );
+  }, [curr, video]);
+
   return video ? (
   return video ? (
     <VideoModal
     <VideoModal
-      src={src + "/" + url}
+      src={url}
       type={video[0].type}
       type={video[0].type}
       trigger={<VideoCameraOutlined />}
       trigger={<VideoCameraOutlined />}
     />
     />