feat: Unit creation button logic and refactoring
This commit is contained in:
committed by
Adolfo R. Brandes
parent
90fb3d8edc
commit
7fcc501d2e
@@ -4,10 +4,10 @@ import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
|
||||
|
||||
import {
|
||||
normalizeLearningSequencesData,
|
||||
normalizeSequenceMetadata,
|
||||
normalizeMetadata,
|
||||
normalizeCourseHomeCourseMetadata,
|
||||
appendBrowserTimezoneToUrl,
|
||||
normalizeCourseSectionVerticalData,
|
||||
} from './utils';
|
||||
|
||||
const getStudioBaseUrl = () => getConfig().STUDIO_BASE_URL;
|
||||
@@ -17,7 +17,6 @@ export const getCourseUnitApiUrl = (itemId) => `${getStudioBaseUrl()}/xblock/con
|
||||
export const postXBlockBaseApiUrl = () => `${getStudioBaseUrl()}/xblock/`;
|
||||
export const getXBlockBaseApiUrl = (itemId) => `${getStudioBaseUrl()}/xblock/${itemId}`;
|
||||
export const getCourseSectionVerticalApiUrl = (itemId) => `${getStudioBaseUrl()}/api/contentstore/v1/container_handler/${itemId}`;
|
||||
export const getSequenceMetadataApiUrl = (sequenceId) => `${getLmsBaseUrl()}/api/courseware/sequence/${sequenceId}`;
|
||||
export const getLearningSequencesOutlineApiUrl = (courseId) => `${getLmsBaseUrl()}/api/learning_sequences/v1/course_outline/${courseId}`;
|
||||
export const getCourseMetadataApiUrl = (courseId) => `${getLmsBaseUrl()}/api/courseware/course/${courseId}`;
|
||||
export const getCourseHomeCourseMetadataApiUrl = (courseId) => `${getLmsBaseUrl()}/api/course_home/course_metadata/${courseId}`;
|
||||
@@ -51,18 +50,6 @@ export async function editUnitDisplayName(unitId, displayName) {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sequence metadata for a given sequence ID.
|
||||
* @param {string} sequenceId - The ID of the sequence for which metadata is requested.
|
||||
* @returns {Promise<Object>} - A Promise that resolves to the normalized sequence metadata.
|
||||
*/
|
||||
export async function getSequenceMetadata(sequenceId) {
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.get(getSequenceMetadataApiUrl(sequenceId), {});
|
||||
|
||||
return normalizeSequenceMetadata(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an object containing course section vertical data.
|
||||
* @param {string} unitId
|
||||
@@ -72,7 +59,7 @@ export async function getCourseSectionVerticalData(unitId) {
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.get(getCourseSectionVerticalApiUrl(unitId));
|
||||
|
||||
return camelCaseObject(data);
|
||||
return normalizeCourseSectionVerticalData(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,11 +101,14 @@ export async function getCourseHomeCourseMetadata(courseId, rootSlug) {
|
||||
return normalizeCourseHomeCourseMetadata(data, rootSlug);
|
||||
}
|
||||
|
||||
export async function createCourseXblock({ type, category, parentLocator }) {
|
||||
export async function createCourseXblock({
|
||||
type, category, parentLocator, displayName,
|
||||
}) {
|
||||
const body = {
|
||||
type,
|
||||
category: category || type,
|
||||
parent_locator: parentLocator,
|
||||
display_name: displayName,
|
||||
};
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.post(postXBlockBaseApiUrl(), body);
|
||||
|
||||
Reference in New Issue
Block a user