mirror of
https://github.com/Luchexx/wacrm.git
synced 2026-11-02 17:29:45 +00:00
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
"use client";
|
|
|
|
import { usePathname } from "next/navigation";
|
|
import { useAuth } from "@/hooks/use-auth";
|
|
import { LogOut } from "lucide-react";
|
|
|
|
const pageTitles: Record<string, string> = {
|
|
"/dashboard": "Dashboard",
|
|
"/inbox": "Inbox",
|
|
"/contacts": "Contacts",
|
|
"/pipelines": "Pipelines",
|
|
"/broadcasts": "Broadcasts",
|
|
"/automations": "Automations",
|
|
"/settings": "Settings",
|
|
};
|
|
|
|
function getPageTitle(pathname: string): string {
|
|
if (pageTitles[pathname]) return pageTitles[pathname];
|
|
|
|
const match = Object.entries(pageTitles).find(([path]) =>
|
|
pathname.startsWith(path)
|
|
);
|
|
return match ? match[1] : "Dashboard";
|
|
}
|
|
|
|
export function Header() {
|
|
const pathname = usePathname();
|
|
const { profile, signOut } = useAuth();
|
|
const title = getPageTitle(pathname);
|
|
|
|
return (
|
|
<header className="flex h-14 shrink-0 items-center justify-between border-b border-slate-800 bg-slate-950 px-6">
|
|
<h1 className="text-lg font-semibold text-white">{title}</h1>
|
|
|
|
<div className="flex items-center gap-3">
|
|
<div className="flex items-center gap-3">
|
|
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-emerald-500/10 text-sm font-medium text-emerald-500">
|
|
{profile?.full_name?.charAt(0)?.toUpperCase() ?? "U"}
|
|
</div>
|
|
<div className="hidden sm:block">
|
|
<p className="text-sm font-medium text-white">
|
|
{profile?.full_name ?? "User"}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<button
|
|
onClick={signOut}
|
|
className="rounded-md p-1.5 text-slate-400 transition-colors hover:bg-slate-800 hover:text-white"
|
|
title="Sign out"
|
|
>
|
|
<LogOut className="h-4 w-4" />
|
|
</button>
|
|
</div>
|
|
</header>
|
|
);
|
|
}
|