diff --git a/src/app/(main)/MobileNav.tsx b/src/app/(main)/MobileNav.tsx
index d3ff51dd..a1944960 100644
--- a/src/app/(main)/MobileNav.tsx
+++ b/src/app/(main)/MobileNav.tsx
@@ -1,15 +1,19 @@
-import { Row, NavMenu, NavMenuItem, IconLabel, Text, Grid } from '@umami/react-zen';
-import { Globe, Grid2x2, LinkIcon } from '@/components/icons';
-import { useMessages, useNavigation } from '@/components/hooks';
-import Link from 'next/link';
import { WebsiteNav } from '@/app/(main)/websites/[websiteId]/WebsiteNav';
-import { Logo } from '@/components/svg';
-import { NavButton } from '@/components/input/NavButton';
+import { useMessages, useNavigation } from '@/components/hooks';
+import { Globe, Grid2x2, LinkIcon } from '@/components/icons';
import { MobileMenuButton } from '@/components/input/MobileMenuButton';
+import { NavButton } from '@/components/input/NavButton';
+import { Logo } from '@/components/svg';
+import { Grid, IconLabel, NavMenu, NavMenuItem, Row, Text } from '@umami/react-zen';
+import Link from 'next/link';
+import { AdminNav } from './admin/AdminNav';
+import { SettingsNav } from './settings/SettingsNav';
export function MobileNav() {
const { formatMessage, labels } = useMessages();
- const { websiteId, renderUrl } = useNavigation();
+ const { pathname, websiteId, renderUrl } = useNavigation();
+ const isAdmin = pathname.includes('/admin');
+ const isSettings = pathname.includes('/settings');
const links = [
{
@@ -51,6 +55,8 @@ export function MobileNav() {
})}
{websiteId && }
+ {isAdmin && }
+ {isSettings && }
>
);
}}
diff --git a/src/app/(main)/admin/AdminLayout.tsx b/src/app/(main)/admin/AdminLayout.tsx
index 4c902d0f..3cc5aed3 100644
--- a/src/app/(main)/admin/AdminLayout.tsx
+++ b/src/app/(main)/admin/AdminLayout.tsx
@@ -1,50 +1,17 @@
'use client';
-import { ReactNode } from 'react';
-import { Grid, Column } from '@umami/react-zen';
-import { useLoginQuery, useMessages, useNavigation } from '@/components/hooks';
-import { User, Users, Globe } from '@/components/icons';
-import { SideMenu } from '@/components/common/SideMenu';
import { PageBody } from '@/components/common/PageBody';
+import { useLoginQuery } from '@/components/hooks';
+import { Column, Grid } from '@umami/react-zen';
+import { ReactNode } from 'react';
+import { AdminNav } from './AdminNav';
export function AdminLayout({ children }: { children: ReactNode }) {
const { user } = useLoginQuery();
- const { formatMessage, labels } = useMessages();
- const { pathname } = useNavigation();
if (!user.isAdmin || process.env.cloudMode) {
return null;
}
- const items = [
- {
- label: formatMessage(labels.manage),
- items: [
- {
- id: 'users',
- label: formatMessage(labels.users),
- path: '/admin/users',
- icon: ,
- },
- {
- id: 'websites',
- label: formatMessage(labels.websites),
- path: '/admin/websites',
- icon: ,
- },
- {
- id: 'teams',
- label: formatMessage(labels.teams),
- path: '/admin/teams',
- icon: ,
- },
- ],
- },
- ];
-
- const selectedKey = items
- .flatMap(e => e.items)
- ?.find(({ path }) => path && pathname.startsWith(path))?.id;
-
return (
-
+
{children}
diff --git a/src/app/(main)/admin/AdminNav.tsx b/src/app/(main)/admin/AdminNav.tsx
new file mode 100644
index 00000000..20c01155
--- /dev/null
+++ b/src/app/(main)/admin/AdminNav.tsx
@@ -0,0 +1,48 @@
+import { SideMenu } from '@/components/common/SideMenu';
+import { useMessages, useNavigation } from '@/components/hooks';
+import { Globe, User, Users } from '@/components/icons';
+
+export function AdminNav({ onItemClick }: { onItemClick?: () => void }) {
+ const { formatMessage, labels } = useMessages();
+ const { pathname } = useNavigation();
+
+ const items = [
+ {
+ label: formatMessage(labels.manage),
+ items: [
+ {
+ id: 'users',
+ label: formatMessage(labels.users),
+ path: '/admin/users',
+ icon: ,
+ },
+ {
+ id: 'websites',
+ label: formatMessage(labels.websites),
+ path: '/admin/websites',
+ icon: ,
+ },
+ {
+ id: 'teams',
+ label: formatMessage(labels.teams),
+ path: '/admin/teams',
+ icon: ,
+ },
+ ],
+ },
+ ];
+
+ const selectedKey = items
+ .flatMap(e => e.items)
+ ?.find(({ path }) => path && pathname.startsWith(path))?.id;
+
+ return (
+
+ );
+}
diff --git a/src/app/(main)/settings/SettingsLayout.tsx b/src/app/(main)/settings/SettingsLayout.tsx
index 787d6c64..fc7b11e7 100644
--- a/src/app/(main)/settings/SettingsLayout.tsx
+++ b/src/app/(main)/settings/SettingsLayout.tsx
@@ -1,50 +1,10 @@
'use client';
import { PageBody } from '@/components/common/PageBody';
-import { SideMenu } from '@/components/common/SideMenu';
-import { useMessages, useNavigation } from '@/components/hooks';
-import { Settings2, UserCircle, Users } from '@/components/icons';
import { Column, Grid } from '@umami/react-zen';
import { ReactNode } from 'react';
+import { SettingsNav } from './SettingsNav';
export function SettingsLayout({ children }: { children: ReactNode }) {
- const { formatMessage, labels } = useMessages();
- const { renderUrl, pathname } = useNavigation();
-
- const items = [
- {
- label: formatMessage(labels.application),
- items: [
- {
- id: 'preferences',
- label: formatMessage(labels.preferences),
- path: renderUrl('/settings/preferences'),
- icon: ,
- },
- ],
- },
- {
- label: formatMessage(labels.account),
- items: [
- {
- id: 'profile',
- label: formatMessage(labels.profile),
- path: renderUrl('/settings/profile'),
- icon: ,
- },
- {
- id: 'teams',
- label: formatMessage(labels.teams),
- path: renderUrl('/settings/teams'),
- icon: ,
- },
- ],
- },
- ];
-
- const selectedKey = items
- .flatMap(e => e.items)
- .find(({ path }) => path && pathname.includes(path.split('?')[0]))?.id;
-
return (
-
+
{children}
diff --git a/src/app/(main)/settings/SettingsNav.tsx b/src/app/(main)/settings/SettingsNav.tsx
new file mode 100644
index 00000000..4b35c82b
--- /dev/null
+++ b/src/app/(main)/settings/SettingsNav.tsx
@@ -0,0 +1,53 @@
+import { SideMenu } from '@/components/common/SideMenu';
+import { useMessages, useNavigation } from '@/components/hooks';
+import { Settings2, UserCircle, Users } from '@/components/icons';
+
+export function SettingsNav({ onItemClick }: { onItemClick?: () => void }) {
+ const { formatMessage, labels } = useMessages();
+ const { renderUrl, pathname } = useNavigation();
+
+ const items = [
+ {
+ label: formatMessage(labels.application),
+ items: [
+ {
+ id: 'preferences',
+ label: formatMessage(labels.preferences),
+ path: renderUrl('/settings/preferences'),
+ icon: ,
+ },
+ ],
+ },
+ {
+ label: formatMessage(labels.account),
+ items: [
+ {
+ id: 'profile',
+ label: formatMessage(labels.profile),
+ path: renderUrl('/settings/profile'),
+ icon: ,
+ },
+ {
+ id: 'teams',
+ label: formatMessage(labels.teams),
+ path: renderUrl('/settings/teams'),
+ icon: ,
+ },
+ ],
+ },
+ ];
+
+ const selectedKey = items
+ .flatMap(e => e.items)
+ .find(({ path }) => path && pathname.includes(path.split('?')[0]))?.id;
+
+ return (
+
+ );
+}