Files
frontend-app-learning/src/courseware/CoursewareRedirect.jsx
Kyle McCormick cf58ff3d3f feat: Use legacy_web_url to redirect to legacy courseware (#404)
As part of making the new courseware experience the
default for staff, the LMS /jump_to/ links that are
exposed by the Course Blocks API via the `lms_web_url`
field will soon direct users to whichever experience
is active to them (instead of always directing to
the legacy experience & relying on the learner
redirect).

Because of this, the MFE can no longer rely on
`lms_web_url` to land a staff user to the legacy
experience. However, the aformentioned change
will also introduce a `legacy_web_url` field
to the API, which we *can* use for this purpose.

TNL-7796
2021-04-07 09:21:07 -04:00

15 lines
427 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.legacyWebUrl || `${getConfig().LMS_BASE_URL}/courses/${courseId}/courseware/`;
global.location.assign(coursewareUrl);
return null;
}