diff --git a/src/app/(frontend)/layout.tsx b/src/app/(frontend)/layout.tsx index f199cdd..74366b6 100644 --- a/src/app/(frontend)/layout.tsx +++ b/src/app/(frontend)/layout.tsx @@ -8,6 +8,7 @@ import { headers as nextHeaders } from "next/headers"; import { SiteHeader } from "@/components/frontend/SiteHeader"; import { Metadata } from "next"; import { resolveLevel, type ResolvedLevel } from "@/utils/xp/resolveLevel"; +import { hasIntelligenceQualification } from "@/utils/access-control/hasIntelligenceQualification"; import { hasLogisticsQualification } from "@/utils/access-control/hasLogisticsQualification"; import { ShipmentToasts } from "@/components/frontend/logistics/ShipmentToasts"; import { GameTickRealtime } from "@/components/frontend/realtime/GameTickRealtime"; @@ -36,10 +37,14 @@ export default async function RootLayout(props: { children: React.ReactNode }) { xp: 0, }; + let isIntelligence = false; let isLogistics = false; if (user) { - isLogistics = await hasLogisticsQualification(payload, user).catch(() => false); + [isIntelligence, isLogistics] = await Promise.all([ + hasIntelligenceQualification(payload, user).catch(() => false), + hasLogisticsQualification(payload, user).catch(() => false), + ]); const [profileRes, experienceRes] = await Promise.all([ payload.find({ collection: "profiles", @@ -80,6 +85,9 @@ export default async function RootLayout(props: { children: React.ReactNode }) { }} xpLevel={xpLevel} adminUrl={payloadConfig.routes.admin} + hasIntelligence={isIntelligence} + hasLogistics={isLogistics} + showCallsign={user.preferences?.display?.showCallsign ?? false} className="border-r" />
diff --git a/src/components/frontend/blocks/AppSidebar.tsx b/src/components/frontend/blocks/AppSidebar.tsx index 949db76..46dde60 100644 --- a/src/components/frontend/blocks/AppSidebar.tsx +++ b/src/components/frontend/blocks/AppSidebar.tsx @@ -1,7 +1,7 @@ "use client"; import * as React from "react"; -import { Bolt, Send, Shield, Users, Warehouse, Crosshair, Backpack } from "lucide-react"; +import { Bolt, Send, Shield, Users, UserCog, Warehouse, Crosshair, Backpack } from "lucide-react"; import { NavCore } from "@/components/frontend/blocks/NavCore"; import { NavSecondary } from "@/components/frontend/blocks/NavSecondary"; @@ -104,6 +104,11 @@ const data = { url: "/locker", icon: Backpack, }, + { + title: "Account", + url: "/account", + icon: UserCog, + }, ], }; @@ -111,6 +116,9 @@ export function AppSidebar({ user, xpLevel, adminUrl, + hasIntelligence = true, + hasLogistics = true, + showCallsign = false, ...props }: { user: { @@ -119,6 +127,9 @@ export function AppSidebar({ }; xpLevel: ResolvedLevel; adminUrl?: string; + hasIntelligence?: boolean; + hasLogistics?: boolean; + showCallsign?: boolean; } & React.ComponentProps) { return ( @@ -147,12 +158,29 @@ export function AppSidebar({ - - - - - - {/**/} + +
+ + {hasIntelligence && ( + + typeof i.items === "object" ? { ...i, items: [...i.items] } : { ...i }, + )} + /> + )} + {hasLogistics && ( + + typeof i.items === "object" ? { ...i, items: [...i.items] } : { ...i }, + )} + /> + )} + + {/**/} +
+
diff --git a/src/components/frontend/blocks/NavUser.tsx b/src/components/frontend/blocks/NavUser.tsx index 0b30507..58ef6d3 100644 --- a/src/components/frontend/blocks/NavUser.tsx +++ b/src/components/frontend/blocks/NavUser.tsx @@ -33,17 +33,22 @@ import { export function NavUser({ user, + showCallsign = false, }: { user: { displayName: string; username: string; avatar: string; }; + showCallsign?: boolean; }) { const { isMobile } = useSidebar(); const router = useRouter(); const [loggingOut, setLoggingOut] = useState(false); + const primaryLine = showCallsign ? user.username : user.displayName; + const secondaryLine = showCallsign ? user.displayName : user.username; + const handleLogout = async () => { setLoggingOut(true); try { @@ -71,8 +76,8 @@ export function NavUser({ CN
- {user.displayName} - {user.username} + {primaryLine} + {secondaryLine}
@@ -92,8 +97,8 @@ export function NavUser({
- {user.displayName} - {user.username} + {primaryLine} + {secondaryLine}
@@ -114,14 +119,16 @@ export function NavUser({ - - - Account - - - - Notifications + + + + Account + + {/* */} + {/* */} + {/* Notifications */} + {/* */} handleLogout()}>