-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
306 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { getCourse, getFullCourseContent } from '@/db/course'; | ||
import { AddContent } from '@/components/admin/AddContent'; | ||
import { AdminCourseContent } from '@/components/admin/CourseContent'; | ||
import findContentById from '@/lib/find-content-by-id'; | ||
|
||
export default async function UpdateCourseContent({ | ||
params, | ||
}: { | ||
params: { courseId: string }; | ||
}) { | ||
const courseId = params.courseId; | ||
const rest: string[] = []; | ||
const course = await getCourse(parseInt(courseId, 10)); | ||
const fullCourseContent = await getFullCourseContent(parseInt(courseId, 10)); | ||
const courseContent = findContentById( | ||
fullCourseContent, | ||
rest.map((x) => parseInt(x, 10)), | ||
); | ||
const contentType = | ||
courseContent?.length === 1 ? courseContent[0]?.type : 'folder'; | ||
|
||
if (contentType === 'video') { | ||
return ( | ||
<div className="mx-auto max-w-screen-xl justify-between p-4 text-white"> | ||
Video | ||
</div> | ||
); | ||
} | ||
|
||
if (contentType === 'notion') { | ||
return ( | ||
<div className="text-blacke mx-auto max-w-screen-xl justify-between p-4 dark:text-white"> | ||
Notion doc | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="mx-auto max-w-screen-xl justify-between p-4 text-black dark:text-white"> | ||
{course?.title} | ||
<div className="font-bold md:text-5xl lg:text-6xl">Content</div> | ||
<AddContent | ||
courseId={parseInt(courseId, 10)} | ||
parentContentId={parseFloat(rest[rest.length - 1])} | ||
/> | ||
<AdminCourseContent | ||
rest={rest} | ||
courseContent={courseContent?.map((x: any) => ({ | ||
title: x?.title || '', | ||
image: x?.thumbnail || '', | ||
id: x?.id || 0, | ||
}))} | ||
courseId={parseInt(courseId, 10)} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import db from '@/db'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
export const POST = async (req: NextRequest) => { | ||
const { | ||
updates, | ||
contentId, | ||
}: { | ||
updates: any; | ||
contentId: number; | ||
} = await req.json(); | ||
|
||
await db.videoMetadata.update({ | ||
where: { | ||
contentId, | ||
}, | ||
data: updates, | ||
}); | ||
|
||
return NextResponse.json({}, { status: 200 }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import db from '@/db'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
export const POST = async (req: NextRequest) => { | ||
const { | ||
updates, | ||
contentId, | ||
}: { | ||
updates: any; | ||
contentId: number; | ||
} = await req.json(); | ||
|
||
await db.videoMetadata.update({ | ||
where: { | ||
contentId, | ||
}, | ||
data: { | ||
video_360p_1: updates.video_360p, | ||
video_360p_2: updates.video_360p, | ||
video_360p_3: updates.video_360p, | ||
video_360p_4: updates.video_360p, | ||
video_720p_1: updates.video_720p, | ||
video_720p_2: updates.video_720p, | ||
video_720p_3: updates.video_720p, | ||
video_720p_4: updates.video_720p, | ||
video_1080p_1: updates.video_1080p, | ||
video_1080p_2: updates.video_1080p, | ||
video_1080p_3: updates.video_1080p, | ||
video_1080p_4: updates.video_1080p, | ||
/// mp4s | ||
|
||
video_1080p_mp4_1: updates.video_1080p_mp4, | ||
video_1080p_mp4_2: updates.video_1080p_mp4, | ||
video_1080p_mp4_3: updates.video_1080p_mp4, | ||
video_1080p_mp4_4: updates.video_1080p_mp4, | ||
video_720p_mp4_1: updates.video_720p_mp4, | ||
video_720p_mp4_2: updates.video_720p_mp4, | ||
video_720p_mp4_3: updates.video_720p_mp4, | ||
video_720p_mp4_4: updates.video_720p_mp4, | ||
video_360p_mp4_1: updates.video_360p_mp4, | ||
video_360p_mp4_2: updates.video_360p_mp4, | ||
video_360p_mp4_3: updates.video_360p_mp4, | ||
video_360p_mp4_4: updates.video_360p_mp4, | ||
}, | ||
}); | ||
|
||
return NextResponse.json({}, { status: 200 }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.