Files
isletmem-kovakcrm/src/components/nav-user.tsx
T
kovakmedya 0a280fd3a3 feat(shell): personalized sidebar + header with real user and company
- Layout split: (dashboard)/layout.tsx is now async server component that
  fetches active context and passes user/company to (dashboard)/dashboard-shell.tsx
  (client). Redirects to /onboarding if no tenant.
- AppSidebar:
  * Header shows 'İşletmem' + the active company name (companyName from
    tenant_settings), instead of mock 'ShadcnStore / Admin Dashboard'.
  * Nav rebuilt for our modules in Turkish: Genel bakış, Müşteriler,
    Hizmetler, Yazılımlarımız, Takvim, Görevler, Gelir/Gider, Faturalar,
    Çalışma alanı (with submenu), Profil, Plan.
  * Removed SidebarNotification (template promo widget).
  * Accepts user/company props (typed via ShellUser/ShellCompany).
- NavUser:
  * Real user name + email, no more 'ShadcnStore / store@example.com'.
  * Avatar shows initials from name in primary/10 tinted square.
  * Logout wired to signOutAction (server action) via useTransition.
  * Menu items localized (Profil, Plan & Faturalama, Bildirimler, Çıkış yap).
- SiteHeader:
  * Removed Blocks / Landing / GitHub external links (template demo links).
  * Shows company name with Building2 icon between sidebar trigger and
    search trigger.
  * Search trigger moved to right side next to ModeToggle.
- Dropped UpgradeToProButton from the shell (template promo).
- Deleted dead-code src/components/layouts/base-layout.tsx (unused alt
  layout that wasn't compatible with the new AppSidebar props).
2026-04-30 03:43:00 +03:00

121 lines
4.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useTransition } from "react";
import {
BellDot,
CircleUser,
CreditCard,
EllipsisVertical,
LogOut,
} from "lucide-react";
import Link from "next/link";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import {
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
useSidebar,
} from "@/components/ui/sidebar";
import { signOutAction } from "@/lib/appwrite/auth-actions";
function initials(name: string) {
const parts = name.trim().split(/\s+/).slice(0, 2);
return parts.map((p) => p[0]?.toUpperCase() ?? "").join("") || "?";
}
export function NavUser({
user,
}: {
user: { name: string; email: string };
}) {
const { isMobile } = useSidebar();
const [isPending, startTransition] = useTransition();
const handleSignOut = () => {
startTransition(async () => {
await signOutAction();
});
};
return (
<SidebarMenu>
<SidebarMenuItem>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<SidebarMenuButton
size="lg"
className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground cursor-pointer"
>
<div className="bg-primary/10 text-primary flex size-8 items-center justify-center rounded-lg text-sm font-medium">
{initials(user.name)}
</div>
<div className="grid flex-1 text-left text-sm leading-tight">
<span className="truncate font-medium">{user.name}</span>
<span className="text-muted-foreground truncate text-xs">{user.email}</span>
</div>
<EllipsisVertical className="ml-auto size-4" />
</SidebarMenuButton>
</DropdownMenuTrigger>
<DropdownMenuContent
className="w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg"
side={isMobile ? "bottom" : "right"}
align="end"
sideOffset={4}
>
<DropdownMenuLabel className="p-0 font-normal">
<div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
<div className="bg-primary/10 text-primary flex size-8 items-center justify-center rounded-lg text-sm font-medium">
{initials(user.name)}
</div>
<div className="grid flex-1 text-left text-sm leading-tight">
<span className="truncate font-medium">{user.name}</span>
<span className="text-muted-foreground truncate text-xs">{user.email}</span>
</div>
</div>
</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem asChild className="cursor-pointer">
<Link href="/settings/account">
<CircleUser />
Profil
</Link>
</DropdownMenuItem>
<DropdownMenuItem asChild className="cursor-pointer">
<Link href="/settings/billing">
<CreditCard />
Plan & Faturalama
</Link>
</DropdownMenuItem>
<DropdownMenuItem asChild className="cursor-pointer">
<Link href="/settings/notifications">
<BellDot />
Bildirimler
</Link>
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={handleSignOut}
disabled={isPending}
className="cursor-pointer"
>
<LogOut />
{isPending ? "Çıkış yapılıyor..." : "Çıkış yap"}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</SidebarMenuItem>
</SidebarMenu>
);
}