Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Button to Redirect Users to Mapped Videos on harkirat.classx #1591

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/actions/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const GetAppxAuthToken = async (): Promise<GetAppxAuthTokenResponse> => {
return user;
};

export const GetAppxVideoPlayerUrl = async (courseId: string, videoId: string): Promise<string> => {
export const GetAppxVideoPlayerUrl = async (courseId: string | number, videoId: string): Promise<string> => {
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}`;

Expand Down
9 changes: 9 additions & 0 deletions src/components/admin/ContentRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
Expand Down Expand Up @@ -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 (
<div>
<ContentRendererClient
AppXVideoUrl={AppXVideoUrl}
nextContent={nextContent}
metadata={metadata}
content={content}
Expand Down
21 changes: 15 additions & 6 deletions src/components/admin/ContentRendererClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const ContentRendererClient = ({
metadata,
content,
nextContent,
AppXVideoUrl,
}: {
nextContent: {
id: number;
Expand All @@ -26,6 +27,7 @@ export const ContentRendererClient = ({
description: string;
markAsCompleted: boolean;
};
AppXVideoUrl?: string;
}) => {
const [showChapters, setShowChapters] = useState(
metadata?.segments?.length > 0,
Expand All @@ -36,7 +38,7 @@ export const ContentRendererClient = ({

//@ts-ignore
const [quality, setQuality] = useState<string>(
searchParams.get('quality') ?? '1080',
searchParams?.get('quality') ?? '1080',
);

if (!metadata) {
Expand Down Expand Up @@ -106,11 +108,18 @@ export const ContentRendererClient = ({
<h2 className="line-clamp-2 text-wrap text-2xl font-extrabold capitalize tracking-tight text-primary md:text-3xl">
{content.title}
</h2>
{metadata.slides ? (
<Link href={metadata.slides} target="_blank">
<Button className="gap-2">Lecture Slides</Button>
</Link>
) : null}
<div>
{metadata.slides ? (
<Link href={metadata.slides} target="_blank">
<Button className="gap-2">Lecture Slides</Button>
</Link>
) : null}
{metadata.appxVideoId !== null && AppXVideoUrl && (
<Link href={AppXVideoUrl} target="_blank">
<Button className="gap-2">View on AppX</Button>
</Link>
)}
</div>
</div>

{!showChapters && metadata.segments?.length > 0 && (
Expand Down
Loading