@lukoweb/apitogo-module-user-panel 0.2.71 → 0.2.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lukoweb/apitogo-module-user-panel",
3
- "version": "0.2.71",
3
+ "version": "0.2.75",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.tsx"
@@ -14,7 +14,7 @@
14
14
  "devDependencies": {
15
15
  "@types/react": "19.2.14",
16
16
  "@types/react-dom": "19.2.3",
17
- "@lukoweb/apitogo": "0.2.71",
17
+ "@lukoweb/apitogo": "0.2.75",
18
18
  "react": "19.2.4",
19
19
  "react-dom": "19.2.4",
20
20
  "react-router": "7.13.1",
@@ -1,135 +1,135 @@
1
- import { cn } from "@lukoweb/apitogo";
2
- import { useAuth } from "@lukoweb/apitogo/hooks";
3
- import {
4
- BookOpenIcon,
5
- CreditCardIcon,
6
- KeyRoundIcon,
7
- LayoutGridIcon,
8
- LogOutIcon,
9
- SettingsIcon,
10
- BarChart3Icon,
11
- } from "@lukoweb/apitogo/icons";
12
- import { Link, NavLink, Outlet } from "@lukoweb/apitogo/router";
13
- import type { ReactNode } from "react";
14
- import {
15
- buildAccountNavPaths,
16
- DEFAULT_ACCOUNT_BASE_PATH,
17
- } from "../account-paths.js";
18
-
19
- type AccountNavItem = {
20
- label: string;
21
- to: string;
22
- icon: typeof LayoutGridIcon;
23
- };
24
-
25
- export type AccountLayoutProps = {
26
- basePath?: string;
27
- /** Where the "Documentation" link goes: a path, an external address, or null for no link (the portal has no docs of its own). */
28
- docsPath?: string | null;
29
- /** The "Overview" entry; a portal that does not register the dashboard page leaves it out. */
30
- includeOverview?: boolean;
31
- children?: ReactNode;
32
- /** When true, show API keys / Usage / Billing (billing plugin routes). */
33
- includeBillingNav?: boolean;
34
- };
35
-
36
- export function AccountLayout({
37
- basePath = DEFAULT_ACCOUNT_BASE_PATH,
38
- docsPath = "/introduction",
39
- includeOverview = true,
40
- children,
41
- includeBillingNav = false,
42
- }: AccountLayoutProps) {
43
- const auth = useAuth();
44
- const paths = buildAccountNavPaths(basePath, docsPath ?? undefined);
45
-
46
- const navItems: AccountNavItem[] = [
47
- ...(includeOverview
48
- ? [{ label: "Overview", to: paths.overview, icon: LayoutGridIcon }]
49
- : []),
50
- ...(includeBillingNav
51
- ? [
52
- { label: "API keys", to: paths.apiKeys, icon: KeyRoundIcon },
53
- { label: "Usage", to: paths.usage, icon: BarChart3Icon },
54
- { label: "Billing", to: paths.billing, icon: CreditCardIcon },
55
- ]
56
- : []),
57
- { label: "Settings", to: paths.settings, icon: SettingsIcon },
58
- ];
59
-
60
- const renderNavLink = (item: AccountNavItem, compact = false) => (
61
- <NavLink
62
- key={item.to}
63
- to={item.to}
64
- end={item.to === paths.overview}
65
- className={({ isActive }) =>
66
- cn(
67
- compact
68
- ? "inline-flex shrink-0 items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition-colors"
69
- : "flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium transition-colors",
70
- isActive
71
- ? "bg-primary/14 font-semibold text-primary"
72
- : "text-muted-foreground hover:bg-muted/80 hover:text-foreground",
73
- )
74
- }
75
- >
76
- <item.icon
77
- size={compact ? 18 : 20}
78
- strokeWidth={1.8}
79
- className="shrink-0 opacity-80"
80
- />
81
- {item.label}
82
- </NavLink>
83
- );
84
-
85
- return (
86
- <div className="flex min-h-[calc(100dvh-var(--header-height))] flex-col bg-muted md:flex-row">
87
- <nav
88
- aria-label="Account"
89
- className="flex gap-1 overflow-x-auto border-b border-border bg-card px-3 py-2 md:hidden"
90
- >
91
- {navItems.map((item) => renderNavLink(item, true))}
92
- </nav>
93
-
94
- <aside className="hidden w-[236px] shrink-0 flex-col justify-between border-r border-border bg-card px-3 py-4 md:flex">
95
- <nav className="flex flex-col gap-1">
96
- {navItems.map((item) => renderNavLink(item))}
97
- </nav>
98
-
99
- <div className="flex flex-col gap-1 border-t border-border pt-3">
100
- {docsPath === null ? null : /^https?:\/\//.test(paths.docs) ? (
101
- <a
102
- href={paths.docs}
103
- className="flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted/80 hover:text-foreground"
104
- >
105
- <BookOpenIcon size={20} strokeWidth={1.8} className="shrink-0" />
106
- Documentation
107
- </a>
108
- ) : (
109
- <Link
110
- to={paths.docs}
111
- className="flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted/80 hover:text-foreground"
112
- >
113
- <BookOpenIcon size={20} strokeWidth={1.8} className="shrink-0" />
114
- Documentation
115
- </Link>
116
- )}
117
- {auth.isAuthEnabled ? (
118
- <button
119
- type="button"
120
- className="flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left text-sm font-medium text-muted-foreground transition-colors hover:bg-muted/80 hover:text-foreground"
121
- onClick={() => {
122
- void auth.logout();
123
- }}
124
- >
125
- <LogOutIcon size={20} strokeWidth={1.8} className="shrink-0" />
126
- Log out
127
- </button>
128
- ) : null}
129
- </div>
130
- </aside>
131
-
132
- <main className="min-w-0 flex-1">{children ?? <Outlet />}</main>
133
- </div>
134
- );
135
- }
1
+ import { cn } from "@lukoweb/apitogo";
2
+ import { useAuth } from "@lukoweb/apitogo/hooks";
3
+ import {
4
+ BookOpenIcon,
5
+ CreditCardIcon,
6
+ KeyRoundIcon,
7
+ LayoutGridIcon,
8
+ LogOutIcon,
9
+ SettingsIcon,
10
+ BarChart3Icon,
11
+ } from "@lukoweb/apitogo/icons";
12
+ import { Link, NavLink, Outlet } from "@lukoweb/apitogo/router";
13
+ import type { ReactNode } from "react";
14
+ import {
15
+ buildAccountNavPaths,
16
+ DEFAULT_ACCOUNT_BASE_PATH,
17
+ } from "../account-paths.js";
18
+
19
+ type AccountNavItem = {
20
+ label: string;
21
+ to: string;
22
+ icon: typeof LayoutGridIcon;
23
+ };
24
+
25
+ export type AccountLayoutProps = {
26
+ basePath?: string;
27
+ /** Where the "Documentation" link goes: a path, an external address, or null for no link (the portal has no docs of its own). */
28
+ docsPath?: string | null;
29
+ /** The "Overview" entry; a portal that does not register the dashboard page leaves it out. */
30
+ includeOverview?: boolean;
31
+ children?: ReactNode;
32
+ /** When true, show API keys / Usage / Billing (billing plugin routes). */
33
+ includeBillingNav?: boolean;
34
+ };
35
+
36
+ export function AccountLayout({
37
+ basePath = DEFAULT_ACCOUNT_BASE_PATH,
38
+ docsPath = "/introduction",
39
+ includeOverview = true,
40
+ children,
41
+ includeBillingNav = false,
42
+ }: AccountLayoutProps) {
43
+ const auth = useAuth();
44
+ const paths = buildAccountNavPaths(basePath, docsPath ?? undefined);
45
+
46
+ const navItems: AccountNavItem[] = [
47
+ ...(includeOverview
48
+ ? [{ label: "Overview", to: paths.overview, icon: LayoutGridIcon }]
49
+ : []),
50
+ ...(includeBillingNav
51
+ ? [
52
+ { label: "API keys", to: paths.apiKeys, icon: KeyRoundIcon },
53
+ { label: "Usage", to: paths.usage, icon: BarChart3Icon },
54
+ { label: "Billing", to: paths.billing, icon: CreditCardIcon },
55
+ ]
56
+ : []),
57
+ { label: "Settings", to: paths.settings, icon: SettingsIcon },
58
+ ];
59
+
60
+ const renderNavLink = (item: AccountNavItem, compact = false) => (
61
+ <NavLink
62
+ key={item.to}
63
+ to={item.to}
64
+ end={item.to === paths.overview}
65
+ className={({ isActive }) =>
66
+ cn(
67
+ compact
68
+ ? "inline-flex shrink-0 items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition-colors"
69
+ : "flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium transition-colors",
70
+ isActive
71
+ ? "bg-primary/14 font-semibold text-primary"
72
+ : "text-muted-foreground hover:bg-muted/80 hover:text-foreground",
73
+ )
74
+ }
75
+ >
76
+ <item.icon
77
+ size={compact ? 18 : 20}
78
+ strokeWidth={1.8}
79
+ className="shrink-0 opacity-80"
80
+ />
81
+ {item.label}
82
+ </NavLink>
83
+ );
84
+
85
+ return (
86
+ <div className="flex min-h-[calc(100dvh-var(--header-height))] flex-col bg-muted md:flex-row">
87
+ <nav
88
+ aria-label="Account"
89
+ className="flex gap-1 overflow-x-auto border-b border-border bg-card px-3 py-2 md:hidden"
90
+ >
91
+ {navItems.map((item) => renderNavLink(item, true))}
92
+ </nav>
93
+
94
+ <aside className="hidden w-[236px] shrink-0 flex-col justify-between border-r border-border bg-card px-3 py-4 md:flex">
95
+ <nav className="flex flex-col gap-1">
96
+ {navItems.map((item) => renderNavLink(item))}
97
+ </nav>
98
+
99
+ <div className="flex flex-col gap-1 border-t border-border pt-3">
100
+ {docsPath === null ? null : /^https?:\/\//.test(paths.docs) ? (
101
+ <a
102
+ href={paths.docs}
103
+ className="flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted/80 hover:text-foreground"
104
+ >
105
+ <BookOpenIcon size={20} strokeWidth={1.8} className="shrink-0" />
106
+ Documentation
107
+ </a>
108
+ ) : (
109
+ <Link
110
+ to={paths.docs}
111
+ className="flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted/80 hover:text-foreground"
112
+ >
113
+ <BookOpenIcon size={20} strokeWidth={1.8} className="shrink-0" />
114
+ Documentation
115
+ </Link>
116
+ )}
117
+ {auth.isAuthEnabled ? (
118
+ <button
119
+ type="button"
120
+ className="flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left text-sm font-medium text-muted-foreground transition-colors hover:bg-muted/80 hover:text-foreground"
121
+ onClick={() => {
122
+ void auth.logout();
123
+ }}
124
+ >
125
+ <LogOutIcon size={20} strokeWidth={1.8} className="shrink-0" />
126
+ Log out
127
+ </button>
128
+ ) : null}
129
+ </div>
130
+ </aside>
131
+
132
+ <main className="min-w-0 flex-1">{children ?? <Outlet />}</main>
133
+ </div>
134
+ );
135
+ }
@@ -1,182 +1,188 @@
1
- import type {
2
- ResolvedDashboardModule,
3
- ResolvedPlansModule,
4
- ResolvedUserManagementModule,
5
- ResolvedUserPanelModule,
6
- } from "@lukoweb/apitogo";
7
- import {
8
- CreditCardIcon,
9
- LayoutDashboardIcon,
10
- SettingsIcon,
11
- } from "@lukoweb/apitogo/icons";
12
- import type {
13
- ProfileMenuPlugin,
14
- ApitogoPlugin,
15
- } from "@lukoweb/apitogo/plugins";
16
- import type { ComponentType, ReactNode } from "react";
17
- import { Navigate, type RouteObject } from "react-router";
18
- import { toAccountChildPath } from "./account-paths.js";
19
- import { AccountLayout } from "./components/AccountLayout.js";
20
- import { DefaultDashboardPage } from "./pages/DefaultDashboardPage.js";
21
- import { DefaultPlansPage } from "./pages/DefaultPlansPage.js";
22
- import { SettingsPage } from "./pages/SettingsPage.js";
23
- import { renderModuleElement } from "./renderModuleElement.js";
24
-
25
- type DashboardModuleOptions = ResolvedDashboardModule & {
26
- component?: ComponentType | ReactNode;
27
- };
28
-
29
- type UserManagementModuleOptions = ResolvedUserManagementModule & {
30
- component?: ComponentType | ReactNode;
31
- };
32
-
33
- type PlansModuleOptions = ResolvedPlansModule & {
34
- component?: ComponentType | ReactNode;
35
- };
36
-
37
- export type UserPanelModuleOptions = ResolvedUserPanelModule & {
38
- dashboard: DashboardModuleOptions;
39
- userManagement: UserManagementModuleOptions;
40
- plans: PlansModuleOptions;
41
- /**
42
- * The billing plugin is on: it owns the plans page (`/account/plans`), so this module registers no placeholder of its
43
- * own, and its pages show the billing plugin's side menu (API keys, Usage, Billing, Settings).
44
- */
45
- billingNav?: boolean;
46
- };
47
-
48
- /** The billing plugin's plans page, where "Plans" leads once that plugin is on. */
49
- const BILLING_PLANS_PATH = "/account/plans";
50
-
51
- const protectAccountRoute = (
52
- protectedRoutes: string[],
53
- enabled: boolean,
54
- path: string,
55
- ) => {
56
- if (enabled) {
57
- protectedRoutes.push(path);
58
- }
59
- };
60
-
61
- export const userPanelModule = (
62
- options: UserPanelModuleOptions,
63
- ): (ApitogoPlugin & ProfileMenuPlugin) | undefined => {
64
- if (!options.enabled) {
65
- return undefined;
66
- }
67
-
68
- const routes: RouteObject[] = [];
69
- const protectedRoutes: string[] = [];
70
- const profileMenuItems: ReturnType<ProfileMenuPlugin["getProfileMenuItems"]> =
71
- [];
72
- const protectAccountRoutes = options.userManagement.enabled;
73
- const basePath = options.basePath ?? "/account";
74
- const accountChildren: RouteObject[] = [];
75
-
76
- if (options.dashboard.enabled) {
77
- accountChildren.push({
78
- path: toAccountChildPath(basePath, options.dashboard.path),
79
- element: renderModuleElement(
80
- options.dashboard.component,
81
- <DefaultDashboardPage content={options.dashboard.content} />,
82
- ),
83
- handle: { layout: "none" },
84
- });
85
- protectAccountRoute(
86
- protectedRoutes,
87
- protectAccountRoutes,
88
- options.dashboard.path,
89
- );
90
- profileMenuItems.push({
91
- label: "Dashboard",
92
- path: options.dashboard.path,
93
- category: "top",
94
- icon: LayoutDashboardIcon,
95
- weight: 10,
96
- });
97
- }
98
-
99
- if (options.userManagement.enabled) {
100
- const profilePath = options.userManagement.routes.profile;
101
- accountChildren.push({
102
- path: toAccountChildPath(basePath, profilePath),
103
- element: renderModuleElement(
104
- options.userManagement.component,
105
- <SettingsPage content={options.userManagement.content} />,
106
- ),
107
- handle: { layout: "none" },
108
- });
109
- protectAccountRoute(protectedRoutes, protectAccountRoutes, profilePath);
110
- profileMenuItems.push({
111
- label: "Settings",
112
- path: profilePath,
113
- category: "middle",
114
- icon: SettingsIcon,
115
- weight: 20,
116
- });
117
- }
118
-
119
- if (options.plans.enabled && options.billingNav) {
120
- // The placeholder would be an empty page next to the real one: its old address leads to the real one instead.
121
- if (options.plans.path !== BILLING_PLANS_PATH)
122
- accountChildren.push({
123
- path: toAccountChildPath(basePath, options.plans.path),
124
- element: <Navigate to={BILLING_PLANS_PATH} replace />,
125
- handle: { layout: "none" },
126
- });
127
- profileMenuItems.push({
128
- label: "Plans",
129
- path: BILLING_PLANS_PATH,
130
- category: "middle",
131
- icon: CreditCardIcon,
132
- weight: 30,
133
- });
134
- } else if (options.plans.enabled) {
135
- accountChildren.push({
136
- path: toAccountChildPath(basePath, options.plans.path),
137
- element: renderModuleElement(
138
- options.plans.component,
139
- <DefaultPlansPage content={options.plans.content} />,
140
- ),
141
- handle: { layout: "none" },
142
- });
143
- protectAccountRoute(protectedRoutes, true, options.plans.path);
144
- profileMenuItems.push({
145
- label: "Plans",
146
- path: options.plans.path,
147
- category: "middle",
148
- icon: CreditCardIcon,
149
- weight: 30,
150
- });
151
- }
152
-
153
- if (options.apiKeys.enabled) {
154
- protectAccountRoute(
155
- protectedRoutes,
156
- protectAccountRoutes,
157
- options.apiKeys.path,
158
- );
159
- }
160
-
161
- if (accountChildren.length > 0) {
162
- routes.push({
163
- path: basePath,
164
- // The same side menu as the billing plugin's pages, and "Overview" only when its page is registered here.
165
- element: (
166
- <AccountLayout
167
- basePath={basePath}
168
- includeOverview={options.dashboard.enabled}
169
- includeBillingNav={options.billingNav === true}
170
- />
171
- ),
172
- handle: { layout: "default" },
173
- children: accountChildren,
174
- });
175
- }
176
-
177
- return {
178
- getRoutes: () => routes,
179
- getProtectedRoutes: () => protectedRoutes,
180
- getProfileMenuItems: () => profileMenuItems,
181
- };
182
- };
1
+ import type {
2
+ ResolvedDashboardModule,
3
+ ResolvedPlansModule,
4
+ ResolvedUserManagementModule,
5
+ ResolvedUserPanelModule,
6
+ } from "@lukoweb/apitogo";
7
+ import {
8
+ CreditCardIcon,
9
+ LayoutDashboardIcon,
10
+ SettingsIcon,
11
+ } from "@lukoweb/apitogo/icons";
12
+ import type {
13
+ ProfileMenuPlugin,
14
+ ApitogoPlugin,
15
+ } from "@lukoweb/apitogo/plugins";
16
+ // The portal's own router, through the core package: a `react-router` of this module's own can be a second copy
17
+ // whose <Navigate> sees no router, which crashed the prerender of `/account/your-plan` (API-110, CI e2e).
18
+ import { Navigate, type RouteObject } from "@lukoweb/apitogo/router";
19
+ import type { ComponentType, ReactNode } from "react";
20
+ import { toAccountChildPath } from "./account-paths.js";
21
+ import { AccountLayout } from "./components/AccountLayout.js";
22
+ import { DefaultDashboardPage } from "./pages/DefaultDashboardPage.js";
23
+ import { DefaultPlansPage } from "./pages/DefaultPlansPage.js";
24
+ import { SettingsPage } from "./pages/SettingsPage.js";
25
+ import { renderModuleElement } from "./renderModuleElement.js";
26
+
27
+ type DashboardModuleOptions = ResolvedDashboardModule & {
28
+ component?: ComponentType | ReactNode;
29
+ };
30
+
31
+ type UserManagementModuleOptions = ResolvedUserManagementModule & {
32
+ component?: ComponentType | ReactNode;
33
+ };
34
+
35
+ type PlansModuleOptions = ResolvedPlansModule & {
36
+ component?: ComponentType | ReactNode;
37
+ };
38
+
39
+ export type UserPanelModuleOptions = ResolvedUserPanelModule & {
40
+ dashboard: DashboardModuleOptions;
41
+ userManagement: UserManagementModuleOptions;
42
+ plans: PlansModuleOptions;
43
+ /**
44
+ * The billing plugin is on: it owns the plans page (`/account/plans`), so this module registers no placeholder of its
45
+ * own, and its pages show the billing plugin's side menu (API keys, Usage, Billing, Settings).
46
+ */
47
+ billingNav?: boolean;
48
+ };
49
+
50
+ /** The billing plugin's plans page, where "Plans" leads once that plugin is on. */
51
+ const BILLING_PLANS_PATH = "/account/plans";
52
+
53
+ const protectAccountRoute = (
54
+ protectedRoutes: string[],
55
+ enabled: boolean,
56
+ path: string,
57
+ ) => {
58
+ if (enabled) {
59
+ protectedRoutes.push(path);
60
+ }
61
+ };
62
+
63
+ export const userPanelModule = (
64
+ options: UserPanelModuleOptions,
65
+ ): (ApitogoPlugin & ProfileMenuPlugin) | undefined => {
66
+ if (!options.enabled) {
67
+ return undefined;
68
+ }
69
+
70
+ const routes: RouteObject[] = [];
71
+ const protectedRoutes: string[] = [];
72
+ const profileMenuItems: ReturnType<ProfileMenuPlugin["getProfileMenuItems"]> =
73
+ [];
74
+ const protectAccountRoutes = options.userManagement.enabled;
75
+ const basePath = options.basePath ?? "/account";
76
+ const accountChildren: RouteObject[] = [];
77
+
78
+ if (options.dashboard.enabled) {
79
+ accountChildren.push({
80
+ path: toAccountChildPath(basePath, options.dashboard.path),
81
+ element: renderModuleElement(
82
+ options.dashboard.component,
83
+ <DefaultDashboardPage content={options.dashboard.content} />,
84
+ ),
85
+ handle: { layout: "none" },
86
+ });
87
+ protectAccountRoute(
88
+ protectedRoutes,
89
+ protectAccountRoutes,
90
+ options.dashboard.path,
91
+ );
92
+ profileMenuItems.push({
93
+ label: "Dashboard",
94
+ path: options.dashboard.path,
95
+ category: "top",
96
+ icon: LayoutDashboardIcon,
97
+ weight: 10,
98
+ });
99
+ }
100
+
101
+ if (options.userManagement.enabled) {
102
+ const profilePath = options.userManagement.routes.profile;
103
+ accountChildren.push({
104
+ path: toAccountChildPath(basePath, profilePath),
105
+ element: renderModuleElement(
106
+ options.userManagement.component,
107
+ <SettingsPage content={options.userManagement.content} />,
108
+ ),
109
+ handle: { layout: "none" },
110
+ });
111
+ protectAccountRoute(protectedRoutes, protectAccountRoutes, profilePath);
112
+ profileMenuItems.push({
113
+ label: "Settings",
114
+ path: profilePath,
115
+ category: "middle",
116
+ icon: SettingsIcon,
117
+ weight: 20,
118
+ });
119
+ }
120
+
121
+ if (options.plans.enabled && options.billingNav) {
122
+ // The placeholder would be an empty page next to the real one: its old address leads to the real one instead.
123
+ if (options.plans.path !== BILLING_PLANS_PATH)
124
+ accountChildren.push({
125
+ path: toAccountChildPath(basePath, options.plans.path),
126
+ element: <Navigate to={BILLING_PLANS_PATH} replace />,
127
+ handle: { layout: "none" },
128
+ });
129
+ profileMenuItems.push({
130
+ label: "Plans",
131
+ path: BILLING_PLANS_PATH,
132
+ category: "middle",
133
+ icon: CreditCardIcon,
134
+ weight: 30,
135
+ });
136
+ } else if (options.plans.enabled) {
137
+ accountChildren.push({
138
+ path: toAccountChildPath(basePath, options.plans.path),
139
+ element: renderModuleElement(
140
+ options.plans.component,
141
+ <DefaultPlansPage content={options.plans.content} />,
142
+ ),
143
+ handle: { layout: "none" },
144
+ });
145
+ protectAccountRoute(protectedRoutes, true, options.plans.path);
146
+ profileMenuItems.push({
147
+ label: "Plans",
148
+ path: options.plans.path,
149
+ category: "middle",
150
+ icon: CreditCardIcon,
151
+ weight: 30,
152
+ });
153
+ }
154
+
155
+ if (options.apiKeys.enabled) {
156
+ protectAccountRoute(
157
+ protectedRoutes,
158
+ protectAccountRoutes,
159
+ options.apiKeys.path,
160
+ );
161
+ }
162
+
163
+ if (accountChildren.length > 0) {
164
+ routes.push({
165
+ path: basePath,
166
+ // The same side menu as the billing plugin's pages, and "Overview" only when its page is registered here.
167
+ element: (
168
+ <AccountLayout
169
+ basePath={basePath}
170
+ includeOverview={options.dashboard.enabled}
171
+ includeBillingNav={options.billingNav === true}
172
+ // The portal's real docs page, or no link: the default `/introduction` was a 404 on most portals (API-110).
173
+ {...(options.docsPath !== undefined
174
+ ? { docsPath: options.docsPath }
175
+ : {})}
176
+ />
177
+ ),
178
+ handle: { layout: "default" },
179
+ children: accountChildren,
180
+ });
181
+ }
182
+
183
+ return {
184
+ getRoutes: () => routes,
185
+ getProtectedRoutes: () => protectedRoutes,
186
+ getProfileMenuItems: () => profileMenuItems,
187
+ };
188
+ };