refactor(app): scope heavy providers to authenticated route layouts

This commit is contained in:
2026-04-03 19:01:48 +02:00
parent df2a6c1759
commit 234da6f7d7
5 changed files with 125 additions and 56 deletions

31
app/(app)/layout.tsx Normal file
View File

@@ -0,0 +1,31 @@
import * as Sentry from "@sentry/nextjs";
import { InitUser } from "@/components/init-user";
import { AppProviders } from "@/components/providers";
import { getAuthUser, getToken } from "@/lib/auth-server";
export default async function AuthenticatedAppLayout({
children,
}: {
children: React.ReactNode;
}) {
const initialToken = await getToken();
const user = await getAuthUser();
if (user) {
const id = user.userId ?? String(user._id);
Sentry.setUser({
id,
email: user.email ?? undefined,
});
} else {
Sentry.setUser(null);
}
return (
<AppProviders initialToken={initialToken}>
<InitUser />
{children}
</AppProviders>
);
}