Revert "AA-133 mfe dates banner (#79)" (#84)

This reverts commit 973f3d68aa.
This commit is contained in:
Nick
2020-06-16 10:14:30 -04:00
committed by GitHub
parent 973f3d68aa
commit 8df4654cf1
10 changed files with 12 additions and 234 deletions

View File

@@ -40,30 +40,12 @@ function normalizeMetadata(metadata) {
};
}
function normalizeCourseHomeCourseMetadata(metadata) {
const data = camelCaseObject(metadata);
return {
...data,
tabs: data.tabs.map(tab => ({
slug: tab.tabId,
title: tab.title,
url: tab.url,
})),
};
}
export async function getCourseMetadata(courseId) {
const url = `${getConfig().LMS_BASE_URL}/api/courseware/course/${courseId}`;
const { data } = await getAuthenticatedHttpClient().get(url);
return normalizeMetadata(data);
}
export async function getCourseHomeCourseMetadata(courseId) {
const url = `${getConfig().LMS_BASE_URL}/api/course_home/v1/course_metadata/${courseId}`;
const { data } = await getAuthenticatedHttpClient().get(url);
return normalizeCourseHomeCourseMetadata(data);
}
export async function getDatesTabData(courseId, version) {
const url = `${getConfig().LMS_BASE_URL}/api/course_home/${version}/dates/${courseId}`;
try {
@@ -226,8 +208,3 @@ export async function getResumeBlock(courseId) {
const { data } = await getAuthenticatedHttpClient().get(url.href, {});
return camelCaseObject(data);
}
export async function updateCourseDeadlines(courseId) {
const url = new URL(`${getConfig().LMS_BASE_URL}/api/course_experience/v1/reset_course_deadlines`);
await getAuthenticatedHttpClient().post(url.href, { course_key: courseId });
}

View File

@@ -5,8 +5,6 @@ import {
getSequenceMetadata,
getDatesTabData,
getOutlineTabData,
getCourseHomeCourseMetadata,
updateCourseDeadlines,
} from './api';
import {
addModelsMap, updateModel, updateModels, updateModelsMap, addModel,
@@ -97,27 +95,24 @@ export function fetchTab(courseId, tab, version, getTabData) {
return async (dispatch) => {
dispatch(fetchTabRequest({ courseId }));
Promise.allSettled([
getCourseHomeCourseMetadata(courseId),
getCourseMetadata(courseId),
getTabData(courseId, version),
]).then(([courseHomeCourseMetadataResult, tabDataResult]) => {
const fetchedCourseHomeMetaData = courseHomeCourseMetadataResult.status === 'fulfilled';
]).then(([courseMetadataResult, tabDataResult]) => {
const fetchedMetadata = courseMetadataResult.status === 'fulfilled';
const fetchedTabData = tabDataResult.status === 'fulfilled';
if (fetchedCourseHomeMetaData) {
if (fetchedMetadata) {
/*
* NOTE: The "courses" models created by this thunk do not include an array of sectionIds.
* If that data is required for some use case, then fetchTab will need to call
* getCourseBlocks as well. See fetchCourse above.
*/
dispatch(addModel({
modelType: 'courseHomeMetadata',
model: {
id: courseId,
...courseHomeCourseMetadataResult.value,
},
modelType: 'courses',
model: courseMetadataResult.value,
}));
} else {
logError(courseHomeCourseMetadataResult.reason);
logError(courseMetadataResult.reason);
}
if (fetchedTabData) {
@@ -132,7 +127,7 @@ export function fetchTab(courseId, tab, version, getTabData) {
logError(tabDataResult.reason);
}
if (fetchedCourseHomeMetaData && fetchedTabData) {
if (fetchedMetadata && fetchedTabData) {
dispatch(fetchTabSuccess({ courseId }));
} else {
dispatch(fetchTabFailure({ courseId }));
@@ -169,13 +164,3 @@ export function fetchSequence(sequenceId) {
}
};
}
export function resetDeadlines(courseId, tab, getTabData) {
return async (dispatch) => {
updateCourseDeadlines(courseId).then(() => {
if (tab === 'dates') {
dispatch(getTabData(courseId));
}
});
};
}