fix: remove Better Auth useSession dependency from portal header
Replace client-side useSession hook with server-side prop passing. Portal layout fetches user email server-side and passes to header. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
cdd897abbc
commit
a123d5e394
2 changed files with 5 additions and 3 deletions
|
|
@ -38,6 +38,7 @@ export default async function PortalLayout({
|
|||
<div className="flex-1 pl-64">
|
||||
<PortalHeader
|
||||
companyName={activeCompany?.display_name}
|
||||
userEmail={session.user.email}
|
||||
isAdmin={isAdmin}
|
||||
unreadNotifications={unreadNotifications}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import { Bell, ChevronDown, LogOut, User } from 'lucide-react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { signOut, useSession } from '@/lib/auth-client';
|
||||
import { signOut } from '@/lib/auth-client';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
|
|
@ -16,17 +16,18 @@ import { Badge } from '@/components/ui/badge';
|
|||
|
||||
type PortalHeaderProps = {
|
||||
companyName?: string;
|
||||
userEmail?: string;
|
||||
isAdmin?: boolean;
|
||||
unreadNotifications?: number;
|
||||
};
|
||||
|
||||
export function PortalHeader({
|
||||
companyName,
|
||||
userEmail,
|
||||
isAdmin,
|
||||
unreadNotifications = 0,
|
||||
}: PortalHeaderProps) {
|
||||
const router = useRouter();
|
||||
const { data: session } = useSession();
|
||||
|
||||
const handleSignOut = async () => {
|
||||
await signOut();
|
||||
|
|
@ -82,7 +83,7 @@ export function PortalHeader({
|
|||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" className="flex items-center space-x-2">
|
||||
<User className="h-5 w-5" />
|
||||
<span className="hidden md:inline">{session?.user?.email}</span>
|
||||
<span className="hidden md:inline">{userEmail}</span>
|
||||
<ChevronDown className="h-4 w-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue