Skip to content

Commit 7dfd7d4

Browse files
arbrandesclaude
andcommitted
feat: add homeApp to redirect / to the dashboard
Adds an inline app that redirects the root route to the learner dashboard via getUrlByRouteRole, shared across dev and build configs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5133932 commit 7dfd7d4

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

site.config.build.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { EnvironmentTypes, SiteConfig, footerApp, headerApp, shellApp } from '@openedx/frontend-base';
22
import { authnApp } from '@openedx/frontend-app-authn';
33
import { learnerDashboardApp } from '@openedx/frontend-app-learner-dashboard';
4+
import homeApp from './src/homeApp';
45

56
import './src/site.scss';
67

@@ -19,6 +20,7 @@ const siteConfig: SiteConfig = {
1920
footerApp,
2021
authnApp,
2122
learnerDashboardApp,
23+
homeApp,
2224
],
2325
externalRoutes: [
2426
{

site.config.dev.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { EnvironmentTypes, SiteConfig, footerApp, headerApp, shellApp } from '@openedx/frontend-base';
22
import { authnApp } from '@openedx/frontend-app-authn';
33
import { learnerDashboardApp } from '@openedx/frontend-app-learner-dashboard';
4+
import homeApp from './src/homeApp';
45

56
import './src/site.scss';
67

@@ -19,6 +20,7 @@ const siteConfig: SiteConfig = {
1920
footerApp,
2021
authnApp,
2122
learnerDashboardApp,
23+
homeApp,
2224
],
2325
externalRoutes: [
2426
{

src/homeApp.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { App, getUrlByRouteRole } from '@openedx/frontend-base';
2+
import { redirect } from 'react-router';
3+
4+
const homeApp: App = {
5+
appId: 'home',
6+
routes: [{
7+
path: '/',
8+
loader: () => {
9+
const dashboardUrl = getUrlByRouteRole('org.openedx.frontend.role.dashboard');
10+
if (dashboardUrl) {
11+
return redirect(dashboardUrl);
12+
}
13+
throw new Response('Not Found', { status: 404 });
14+
},
15+
}],
16+
};
17+
18+
export default homeApp;

0 commit comments

Comments
 (0)