From 5c8acb0991c7c663f06dc884b47bcaa642788101 Mon Sep 17 00:00:00 2001 From: Smnthjm08 Date: Thu, 28 Nov 2024 20:46:39 +0530 Subject: [PATCH] feat: Button to Redirect Users to Mapped Videos on harkirat.classx --- src/actions/user/index.ts | 2 +- src/components/admin/ContentRenderer.tsx | 9 ++++++++ .../admin/ContentRendererClient.tsx | 21 +++++++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/actions/user/index.ts b/src/actions/user/index.ts index 7f6f960a..82e7d13c 100644 --- a/src/actions/user/index.ts +++ b/src/actions/user/index.ts @@ -56,7 +56,7 @@ export const GetAppxAuthToken = async (): Promise => { return user; }; -export const GetAppxVideoPlayerUrl = async (courseId: string, videoId: string): Promise => { +export const GetAppxVideoPlayerUrl = async (courseId: string | number, videoId: string): Promise => { const { name, email, appxAuthToken, appxUserId } = await GetAppxAuthToken(); const url = `${process.env.APPX_BASE_API}/get/fetchVideoDetailsById?course_id=${courseId}&video_id=${videoId}&ytflag=${1}&folder_wise_course=${1}`; diff --git a/src/components/admin/ContentRenderer.tsx b/src/components/admin/ContentRenderer.tsx index c6b5c35f..3003a6dc 100644 --- a/src/components/admin/ContentRenderer.tsx +++ b/src/components/admin/ContentRenderer.tsx @@ -3,6 +3,7 @@ import { getServerSession } from 'next-auth'; import { authOptions } from '@/lib/auth'; import { ContentRendererClient } from './ContentRendererClient'; import { Bookmark } from '@prisma/client'; +import { GetAppxVideoPlayerUrl } from '@/actions/user'; function bunnyUrl(url?: string) { if (!url) return ''; @@ -144,12 +145,20 @@ export const ContentRenderer = async ({ slides?: string; markAsCompleted: boolean; bookmark: Bookmark | null; + AppXVideoId?: string; }; }) => { const metadata = await getMetadata(content.id); + let AppXVideoUrl = null; + + if (metadata?.appxVideoId !== null) { + AppXVideoUrl = await GetAppxVideoPlayerUrl(content.id, metadata.appxVideoId); + } + return (
{ const [showChapters, setShowChapters] = useState( metadata?.segments?.length > 0, @@ -36,7 +38,7 @@ export const ContentRendererClient = ({ //@ts-ignore const [quality, setQuality] = useState( - searchParams.get('quality') ?? '1080', + searchParams?.get('quality') ?? '1080', ); if (!metadata) { @@ -106,11 +108,18 @@ export const ContentRendererClient = ({

{content.title}

- {metadata.slides ? ( - - - - ) : null} +
+ {metadata.slides ? ( + + + + ) : null} + {metadata.appxVideoId !== null && AppXVideoUrl && ( + + + + )} +
{!showChapters && metadata.segments?.length > 0 && (