add
This commit is contained in:
parent
0e9ac6713a
commit
cbba92b380
|
@ -13,6 +13,7 @@ import { LectureType, LessonTypeLabel, PostType } from "@nice/common";
|
|||
import { usePost } from "@nice/client";
|
||||
import toast from "react-hot-toast";
|
||||
import { LectureData } from "./interface";
|
||||
import { env } from "@web/src/env";
|
||||
|
||||
interface SortableLectureProps {
|
||||
field: LectureData;
|
||||
|
@ -43,6 +44,11 @@ export const SortableLecture: React.FC<SortableLectureProps> = ({
|
|||
setLoading(true);
|
||||
const values = await form.validateFields();
|
||||
let result;
|
||||
const videoUrlId = Array.isArray(values?.videoUrlIds)
|
||||
? values.videoUrlIds[0]
|
||||
: typeof values?.videoUrlIds === "string"
|
||||
? values.videoUrlIds
|
||||
: undefined;
|
||||
|
||||
if (!field.id) {
|
||||
result = await create.mutateAsync({
|
||||
|
@ -52,14 +58,17 @@ export const SortableLecture: React.FC<SortableLectureProps> = ({
|
|||
title: values?.title,
|
||||
meta: {
|
||||
type: values?.meta?.type,
|
||||
fileIds: values?.meta?.fileIds,
|
||||
// fileIds: values?.meta?.fileIds,
|
||||
videoUrl: videoUrlId
|
||||
? `http://${env.SERVER_IP}:${env.FILE_PORT}/uploads/${videoUrlId}/stream/index.m3u8`
|
||||
: undefined,
|
||||
},
|
||||
resources: {
|
||||
connect: (values?.meta?.fileIds || []).map(
|
||||
(fileId) => ({
|
||||
connect: [videoUrlId]
|
||||
.filter(Boolean)
|
||||
.map((fileId) => ({
|
||||
fileId,
|
||||
})
|
||||
),
|
||||
})),
|
||||
},
|
||||
content: values?.content,
|
||||
},
|
||||
|
@ -73,14 +82,16 @@ export const SortableLecture: React.FC<SortableLectureProps> = ({
|
|||
title: values?.title,
|
||||
meta: {
|
||||
type: values?.meta?.type,
|
||||
fieldIds: values?.meta?.fileIds,
|
||||
videoUrl: videoUrlId
|
||||
? `http://${env.SERVER_IP}:${env.FILE_PORT}/uploads/${videoUrlId}/stream/index.m3u8`
|
||||
: undefined,
|
||||
},
|
||||
resources: {
|
||||
connect: (values?.meta?.fileIds || []).map(
|
||||
(fileId) => ({
|
||||
connect: [videoUrlId]
|
||||
.filter(Boolean)
|
||||
.map((fileId) => ({
|
||||
fileId,
|
||||
})
|
||||
),
|
||||
})),
|
||||
},
|
||||
content: values?.content,
|
||||
},
|
||||
|
@ -135,7 +146,7 @@ export const SortableLecture: React.FC<SortableLectureProps> = ({
|
|||
<div className="mt-4 flex flex-1 ">
|
||||
{lectureType === LectureType.VIDEO ? (
|
||||
<Form.Item
|
||||
name={["meta", "fileIds"]}
|
||||
name={"videoUrlIds"}
|
||||
className="mb-0 flex-1"
|
||||
rules={[{ required: true }]}>
|
||||
<TusUploader multiple={false} />
|
||||
|
|
Loading…
Reference in New Issue