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">
|
<div className="flex-1 pl-64">
|
||||||
<PortalHeader
|
<PortalHeader
|
||||||
companyName={activeCompany?.display_name}
|
companyName={activeCompany?.display_name}
|
||||||
|
userEmail={session.user.email}
|
||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
unreadNotifications={unreadNotifications}
|
unreadNotifications={unreadNotifications}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import { Bell, ChevronDown, LogOut, User } from 'lucide-react';
|
import { Bell, ChevronDown, LogOut, User } from 'lucide-react';
|
||||||
import { useRouter } from 'next/navigation';
|
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 { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
|
|
@ -16,17 +16,18 @@ import { Badge } from '@/components/ui/badge';
|
||||||
|
|
||||||
type PortalHeaderProps = {
|
type PortalHeaderProps = {
|
||||||
companyName?: string;
|
companyName?: string;
|
||||||
|
userEmail?: string;
|
||||||
isAdmin?: boolean;
|
isAdmin?: boolean;
|
||||||
unreadNotifications?: number;
|
unreadNotifications?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function PortalHeader({
|
export function PortalHeader({
|
||||||
companyName,
|
companyName,
|
||||||
|
userEmail,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
unreadNotifications = 0,
|
unreadNotifications = 0,
|
||||||
}: PortalHeaderProps) {
|
}: PortalHeaderProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { data: session } = useSession();
|
|
||||||
|
|
||||||
const handleSignOut = async () => {
|
const handleSignOut = async () => {
|
||||||
await signOut();
|
await signOut();
|
||||||
|
|
@ -82,7 +83,7 @@ export function PortalHeader({
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button variant="ghost" className="flex items-center space-x-2">
|
<Button variant="ghost" className="flex items-center space-x-2">
|
||||||
<User className="h-5 w-5" />
|
<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" />
|
<ChevronDown className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue