diff --git a/components/layout/SidebarList.jsx b/components/layout/SidebarList.jsx
index 819db0e..f1bddd1 100644
--- a/components/layout/SidebarList.jsx
+++ b/components/layout/SidebarList.jsx
@@ -60,8 +60,8 @@ export default function SidebarList({ filters, setFilters }) {
diff --git a/components/tabs/textImagePanel.js b/components/tabs/textImagePanel.js
index 4f281de..d25fe8f 100644
--- a/components/tabs/textImagePanel.js
+++ b/components/tabs/textImagePanel.js
@@ -159,7 +159,13 @@ export default function TextImagePanel({ filters }) {
- } type="submit">
+ }
+ type="submit"
+ isLoading={isGeneratingImage}
+ >
اجرا
diff --git a/components/tabs/textVideoPanel.js b/components/tabs/textVideoPanel.js
index 3b7a788..2c26981 100644
--- a/components/tabs/textVideoPanel.js
+++ b/components/tabs/textVideoPanel.js
@@ -22,12 +22,35 @@ import { TbPrompt } from "react-icons/tb";
import { FaDraft2Digital, FaPlay } from "react-icons/fa";
import { useForm } from "react-hook-form";
import ResultBox from "../ui/ResultBox";
+import axiosInstance, { baseUrl } from "@/lib/api";
+import useSWRMutation from "swr/mutation";
+import { useState } from "react";
-export default function TextVideoPanel() {
+const modelsDic = {
+ cogvideo_base: "base",
+ cogvideo_lora: "lora",
+};
+
+const postRequest = async (url, { arg }) => {
+ const response = await axiosInstance.post(baseUrl + url, arg);
+ return response?.data;
+};
+
+export default function TextVideoPanel({ filters }) {
const { register, handleSubmit } = useForm();
+ const [videos, setVideos] = useState([]);
- const addSubmit = (e) => {
- console.log(e);
+ const { trigger: triggerGenerateVideo, isMutating: isGeneratingVideo } =
+ useSWRMutation(
+ `/content/cogvideo/${modelsDic[filters?.tab_menu]}`,
+ postRequest,
+ {
+ onSuccess: (data) => setVideos(data?.videos),
+ },
+ );
+
+ const onSubmit = (data) => {
+ triggerGenerateVideo(data);
};
return (
@@ -38,7 +61,7 @@ export default function TextVideoPanel() {
alignItems="start"
overflowY="auto"
as={"form"}
- onSubmit={handleSubmit(addSubmit)}
+ onSubmit={handleSubmit(onSubmit)}
>
{" "}
@@ -55,11 +78,11 @@ export default function TextVideoPanel() {
/>
تعداد فریم ها:
-
+
seed:
-
+
@@ -75,7 +98,7 @@ export default function TextVideoPanel() {
/>
مقیاس راهنمایی:
-
+
@@ -88,9 +111,9 @@ export default function TextVideoPanel() {
border={"1px"}
borderColor={"gray.300"}
/>
- تعداد:
+ تعداد مراحل استنتاج:
-
+
@@ -108,7 +131,13 @@ export default function TextVideoPanel() {
- } type="submit">
+ }
+ type="submit"
+ isLoading={isGeneratingVideo}
+ >
اجرا
@@ -123,7 +152,7 @@ export default function TextVideoPanel() {
-
+
);
}
diff --git a/components/ui/ResultBox.jsx b/components/ui/ResultBox.jsx
index 4617a8b..9506c87 100644
--- a/components/ui/ResultBox.jsx
+++ b/components/ui/ResultBox.jsx
@@ -95,11 +95,11 @@ function ResultBox({
)}
- {type === "image" && loading && (
+ {(type === "image" || type === "video") && loading && (
- در حال تولید تصویر...
+ در حال تولید {type === "image" ? "تصویر" : "ویدئو"}...
)}
+
+ {type === "video" && !loading && resultData?.[0] && (
+
+
+
+
+
+ )}
);
diff --git a/pages/index.js b/pages/index.js
index 76b8e23..24e1149 100644
--- a/pages/index.js
+++ b/pages/index.js
@@ -182,7 +182,7 @@ export default function Home() {
-
+
مرج نهایی