import { whopSdk } from "@/lib/whop-sdk";

const result = await whopSdk.courses.updateChapterOrder({
	// The ID of the chapter to place this chapter below
	belowChapterId: "xxxxxxxxxxx",

	// The ID of the chapter to reorder
	chapterId: "xxxxxxxxxxx" /* Required! */,
});

Example output:

const response = {
	// The ID of the chapter. Looks like chap_XXX
	id: "xxxxxxxxxxx",

	// The title of the chapter
	title: "some string",

	// The order of the chapter within its course
	order: 10,

	// The lessons in this chapter
	lessons: [
		{
			// The ID of the lesson
			id: "xxxxxxxxxxx",

			// The type of the lesson (text, video, pdf, multi, quiz, knowledge_check)
			lessonType:
				"knowledge_check" /* Valid values: knowledge_check | multi | pdf | quiz | text | video */,

			// The title of the lesson
			title: "some string",

			// The order of the lesson within its chapter
			order: 10,

			// Number of days from course start until the lesson is unlocked
			daysFromCourseStartUntilUnlock: 10,

			// The content of the lesson
			content: "some string",

			// The associated Mux asset for video lessons
			muxAsset: {
				// The ID of the Mux asset
				id: "xxxxxxxxxxx",

				// The Mux-provided ID of the asset
				muxAssetId: "some string",

				// The public playback ID of the Mux asset
				playbackId: "some string",

				// The signed playback ID of the Mux asset
				signedPlaybackId: "some string",

				// The signed thumbnail playback token of the Mux asset
				signedThumbnailPlaybackToken: "some string",

				// The signed video playback token of the Mux asset
				signedVideoPlaybackToken: "some string",

				// The signed storyboard playback token of the Mux asset
				signedStoryboardPlaybackToken: "some string",

				// The duration of the video in seconds
				durationSeconds: 10,

				// The status of the Mux asset
				status: "created" /* Valid values: created | ready | uploading */,

				// The time at which the video finished uploading
				finishedUploadingAt: 1716931200,
			},
		},
	],
};