|
|
@@ -1,7 +1,11 @@
|
|
|
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";
|
|
|
|
|
|
export interface IVideo {
|
|
|
+ videoId: string;
|
|
|
url?: string;
|
|
|
type?: string;
|
|
|
title?: string;
|
|
|
@@ -10,13 +14,23 @@ interface IWidget {
|
|
|
video: IVideo[];
|
|
|
}
|
|
|
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 ? (
|
|
|
<VideoModal
|
|
|
- src={src + "/" + url}
|
|
|
+ src={url}
|
|
|
type={video[0].type}
|
|
|
trigger={<VideoCameraOutlined />}
|
|
|
/>
|