Files
claudemesh/apps/web/src/app/[locale]/dashboard/(user)/layout.tsx
Alejandro Gutiérrez e6e76d1b9a
Some checks failed
CI / Tests / 🧪 Test (push) Has been cancelled
feat(web): account data export + sidebar rebrand to "Account"
Step 16 (account / profile) — landed smaller than scoped because turbo-
starter already ships the full /dashboard/settings flow (avatar, name,
email, language, delete-account) and BetterAuth handles security +
sessions out of the box. Reuses that surface; adds the claudemesh-
specific bits only.

- GET /api/my/export — returns a JSON bundle of the user's profile,
  meshes they own, meshes they belong to, invites they've issued, and
  audit events from their OWNED meshes (privacy: don't leak events
  from meshes merely joined). Limited to 5k audit rows.
- ExportData component on /dashboard/settings — button downloads the
  bundle as claudemesh-export-<userId>-<YYYY-MM-DD>.json client-side.
- Sidebar (user group) "settings" label swapped to "account" to match
  the Step 16 naming. Same /dashboard/settings route, same existing
  i18n key ("account" was already in common.json).

No schema changes: user.name (BetterAuth) IS the mesh display name.
meshMember.displayName is the per-join override that lands from the
CLI at registration time.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 23:03:23 +01:00

75 lines
1.6 KiB
TypeScript

import { redirect } from "next/navigation";
import { Icons } from "@turbostarter/ui-web/icons";
import { SidebarProvider } from "@turbostarter/ui-web/sidebar";
import { pathsConfig } from "~/config/paths";
import { getSession } from "~/lib/auth/server";
import { DashboardInset } from "~/modules/common/layout/dashboard/inset";
import { DashboardSidebar } from "~/modules/common/layout/dashboard/sidebar";
/**
* Dashboard sidebar menu configuration.
*/
const menu = [
{
label: "platform",
items: [
{
title: "dashboard",
href: pathsConfig.dashboard.user.index,
icon: Icons.Home,
},
{
title: "meshes",
href: pathsConfig.dashboard.user.meshes.index,
icon: Icons.Share,
},
{
title: "invites",
href: pathsConfig.dashboard.user.invites,
icon: Icons.Link,
},
],
},
{
label: "manage",
items: [
{
title: "account",
href: pathsConfig.dashboard.user.settings.index,
icon: Icons.Settings,
},
],
},
{
label: "dev",
items: [
{
title: "demos",
href: pathsConfig.demo.index,
icon: Icons.LayoutDashboard,
},
],
},
];
export default async function DashboardLayout({
children,
}: {
children: React.ReactNode;
}) {
const { user } = await getSession();
if (!user) {
return redirect(pathsConfig.auth.login);
}
return (
<SidebarProvider>
<DashboardSidebar user={user} menu={menu} />
<DashboardInset>{children}</DashboardInset>
</SidebarProvider>
);
}