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>
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
import { Switch, Route, useRouteMatch } from 'react-router';
|
|
import { getConfig } from '@edx/frontend-platform';
|
|
import { FormattedMessage } from '@edx/frontend-platform/i18n';
|
|
|
|
import PageLoading from '../generic/PageLoading';
|
|
import CoursewareRedirect from './CoursewareRedirect';
|
|
|
|
export default () => {
|
|
const { path } = useRouteMatch();
|
|
return (
|
|
<div className="flex-grow-1">
|
|
<PageLoading srMessage={(
|
|
<FormattedMessage
|
|
id="learn.redirect.interstitial.message"
|
|
description="The screen-reader message when a page is about to redirect"
|
|
defaultMessage="Redirecting..."
|
|
/>
|
|
)}
|
|
/>
|
|
|
|
<Switch>
|
|
<Route
|
|
path={`${path}/courseware/:courseId/unit/:unitId`}
|
|
component={CoursewareRedirect}
|
|
/>
|
|
<Route
|
|
path={`${path}/course-home/:courseId`}
|
|
render={({ match }) => {
|
|
global.location.assign(`${getConfig().LMS_BASE_URL}/courses/${match.params.courseId}/course/`);
|
|
}}
|
|
/>
|
|
<Route
|
|
path={`${path}/dashboard`}
|
|
render={({ location }) => {
|
|
global.location.assign(`${getConfig().LMS_BASE_URL}/dashboard${location.search}`);
|
|
}}
|
|
/>
|
|
</Switch>
|
|
</div>
|
|
);
|
|
};
|