import type { PropsWithChildren } from "react"; import Link from "next/link"; import { notFound } from "next/navigation"; import { Button, Grid, GridCol, Group, Stack, Text, Title } from "@mantine/core"; import { IconSettings, IconShieldLock } from "@tabler/icons-react"; import { api } from "@homarr/api/server"; import { auth } from "@homarr/auth/next"; import { getI18n, getScopedI18n } from "@homarr/translation/server"; import { UserAvatar } from "@homarr/ui"; import { ManageContainer } from "~/components/manage/manage-container"; import { catchTrpcNotFound } from "~/errors/trpc-not-found"; import { NavigationLink } from "../groups/[id]/_navigation"; import { canAccessUserEditPage } from "./access"; interface LayoutProps { params: { userId: string }; } export default async function Layout({ children, params }: PropsWithChildren) { const session = await auth(); const t = await getI18n(); const tUser = await getScopedI18n("management.page.user"); const user = await api.user.getById({ userId: params.userId }).catch(catchTrpcNotFound); if (!canAccessUserEditPage(session, user.id)) { notFound(); } return ( {user.name} {t("user.name")} {session?.user.permissions.includes("admin") && ( )} } /> } /> {children} ); }