Files
frontend-app-learning/src/courseware/CoursewareRedirect.jsx
David Joy c298bc1dbf Implement kill-switch for non-staff users
to redirect to the current unit’s lmsWebUrl if the MFE is disabled

If we receive an error_code of 'microfrontend_disabled',
go to the equivalent unit in the LMS experience.

Fixes: TNL-7362
Co-authored-by: stvn <stvn@mit.edu>
2020-08-12 17:26:30 -07:00

15 lines
424 B
JavaScript

import { getConfig } from '@edx/frontend-platform';
import { useModel } from '../generic/model-store';
export default function CourseRedirect({ match }) {
const {
courseId,
unitId,
} = match.params;
const unit = useModel('units', unitId) || {};
const coursewareUrl = unit.lmsWebUrl || `${getConfig().LMS_BASE_URL}/courses/${courseId}/courseware/`;
global.location.assign(coursewareUrl);
return null;
}