From c2a198233442887e3d27a7abbf8d466726ce9ef6 Mon Sep 17 00:00:00 2001 From: Sargam Poudel Date: Mon, 2 Dec 2024 18:25:32 +0530 Subject: [PATCH] fix: video not loading issue --- src/components/VideoPlayer2.tsx | 4 ++-- src/components/admin/ContentRenderer.tsx | 11 +++++------ src/utiles/appx.ts | 17 +++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/VideoPlayer2.tsx b/src/components/VideoPlayer2.tsx index 6cbdd468..07bf5cf4 100644 --- a/src/components/VideoPlayer2.tsx +++ b/src/components/VideoPlayer2.tsx @@ -41,7 +41,7 @@ export const VideoPlayer: FunctionComponent = ({ subtitles, onVideoEnd, appxVideoId, - appxCourseId + appxCourseId, }) => { const videoRef = useRef(null); const playerRef = useRef(null); @@ -484,7 +484,7 @@ export const VideoPlayer: FunctionComponent = ({ return (
diff --git a/src/components/admin/ContentRenderer.tsx b/src/components/admin/ContentRenderer.tsx index 99a70e18..eb5b1663 100644 --- a/src/components/admin/ContentRenderer.tsx +++ b/src/components/admin/ContentRenderer.tsx @@ -149,12 +149,11 @@ export const ContentRenderer = async ({ }; }) => { const metadata = await getMetadata(content.id); - const appxCourseId = await getAppxCourseId(content.courseId); - if (!appxCourseId) { - return
Loading...
; - } - //@ts-ignore - const appxVideoId: string = metadata?.appxVideoJSON[appxCourseId]; + const result = await getAppxCourseId(content.courseId); + const appxCourseId = typeof result !== 'string' ? '' : result; + + // @ts-ignore + const appxVideoId: string = metadata?.appxVideoJSON?.[appxCourseId] ?? ''; return (
diff --git a/src/utiles/appx.ts b/src/utiles/appx.ts index 90c490bc..8c22fe97 100644 --- a/src/utiles/appx.ts +++ b/src/utiles/appx.ts @@ -231,21 +231,22 @@ export async function getAppxCourseId(courseId: string) { course: true, }, orderBy: { - courseId: 'asc' - } + courseId: 'asc', + }, }); const CMS_APPX_COURSE_MAP: Record = { - 13: ["8", "10"], - 14: ["8", "9", "11"], - 15: ["8", "9", "12"] + 13: ['8', '10'], + 14: ['8', '9', '11'], + 15: ['8', '9', '12'], }; let appxCourseId: string | null = null; - parentCourses.forEach((pc => { - if (CMS_APPX_COURSE_MAP[courseId].includes(pc.courseId.toString())) { + if (!CMS_APPX_COURSE_MAP[courseId]) return ''; + parentCourses.forEach((pc) => { + if (CMS_APPX_COURSE_MAP[courseId]?.includes(pc.courseId.toString())) { appxCourseId = pc.course.appxCourseId; } - })); + }); return appxCourseId; }