Skip to content

Commit

Permalink
feat: strawman for ENT-8078
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnage101 committed Dec 12, 2023
1 parent e004ead commit 7166020
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ export const ROUTES = {
UNSUBSCRIBE: '/goal-unsubscribe/:token',
REDIRECT: '/redirect/*',
DASHBOARD: 'dashboard',
ENTERPRISE_LEARNER_DASHBOARD: 'enterprise-learner-dashboard',
CONSENT: 'consent',
};

export const REDIRECT_MODES = {
DASHBOARD_REDIRECT: 'dashboard-redirect',
ENTERPRISE_LEARNER_DASHBOARD_REDIRECT: 'enterprise-learner-dashboard-redirect',
CONSENT_REDIRECT: 'consent-redirect',
HOME_REDIRECT: 'home-redirect',
SURVEY_REDIRECT: 'survey-redirect',
Expand Down
11 changes: 11 additions & 0 deletions src/courseware/CoursewareRedirectLandingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ const CoursewareRedirectLandingPage = () => (
path={ROUTES.DASHBOARD}
element={<PageWrap><RedirectPage pattern="/dashboard" mode={REDIRECT_MODES.DASHBOARD_REDIRECT} /></PageWrap>}
/>
<Route
path={ROUTES.ENTERPRISE_LEARNER_DASHBOARD}
element={
<PageWrap>

Check failure on line 35 in src/courseware/CoursewareRedirectLandingPage.jsx

View workflow job for this annotation

GitHub Actions / tests

Missing parentheses around multilines JSX
<RedirectPage

Check failure on line 36 in src/courseware/CoursewareRedirectLandingPage.jsx

View workflow job for this annotation

GitHub Actions / tests

Expected indentation of 12 space characters but found 10
pattern="/enterprise-learner-dashboard"
mode={REDIRECT_MODES.ENTERPRISE_LEARNER_DASHBOARD_REDIRECT}
/>
</PageWrap>
}
/>
<Route
path={ROUTES.CONSENT}
element={<PageWrap><RedirectPage mode={REDIRECT_MODES.CONSENT_REDIRECT} /></PageWrap>}
Expand Down
14 changes: 10 additions & 4 deletions src/courseware/RedirectPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,26 @@ const RedirectPage = ({
const location = useLocation();
const { consentPath } = queryString.parse(location?.search);

const BASE_URL = getConfig().LMS_BASE_URL;
const {
LMS_BASE_URL,
ENTERPRISE_LEARNER_PORTAL_URL,
} = getConfig();

switch (mode) {
case REDIRECT_MODES.DASHBOARD_REDIRECT:
global.location.assign(`${BASE_URL}${pattern}${location?.search}`);
global.location.assign(`${LMS_BASE_URL}${pattern}${location?.search}`);
break;
case REDIRECT_MODES.ENTERPRISE_LEARNER_DASHBOARD_REDIRECT:
global.location.assign(ENTERPRISE_LEARNER_PORTAL_URL);
break;
case REDIRECT_MODES.CONSENT_REDIRECT:
global.location.assign(`${BASE_URL}${consentPath}`);
global.location.assign(`${LMS_BASE_URL}${consentPath}`);
break;
case REDIRECT_MODES.HOME_REDIRECT:
global.location.assign(generatePath(pattern, { courseId }));
break;
default:
global.location.assign(`${BASE_URL}${generatePath(pattern, { courseId })}`);
global.location.assign(`${LMS_BASE_URL}${generatePath(pattern, { courseId })}`);
}

return null;
Expand Down
3 changes: 3 additions & 0 deletions src/shared/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export function getAccessDeniedRedirectUrl(courseId, activeTabSlug, courseAccess
const startDate = (new Intl.DateTimeFormat(getLocale())).format(new Date(start));
url = `/redirect/dashboard?notlive=${startDate}`;
break;
case 'course_not_started_enterprise_learner':
url = '/redirect/enterprise-learner-dashboard';
break;
case 'survey_required':
url = `/redirect/survey/${courseId}`;
break;
Expand Down

0 comments on commit 7166020

Please sign in to comment.