166 lines
5.6 KiB
TypeScript
166 lines
5.6 KiB
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { usePathname } from "next/navigation";
|
|
import { signOut } from "@/utils/profile/profile";
|
|
import Image from "next/image";
|
|
|
|
const navItems = [
|
|
{
|
|
label: "Rooms",
|
|
href: "/rooms",
|
|
icon: (
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
viewBox="0 0 24 24"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
strokeWidth={1.5}
|
|
className="size-5"
|
|
>
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
d="M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.076-4.076a1.526 1.526 0 0 1 1.037-.443 48.282 48.282 0 0 0 5.68-.494c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z"
|
|
/>
|
|
</svg>
|
|
),
|
|
},
|
|
{
|
|
label: "Friends",
|
|
href: "/friends",
|
|
icon: (
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
viewBox="0 0 24 24"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
strokeWidth={1.5}
|
|
className="size-5"
|
|
>
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
d="M15 19.128a9.38 9.38 0 0 0 2.625.372 9.337 9.337 0 0 0 4.121-.952 4.125 4.125 0 0 0-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 0 1 8.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0 1 11.964-3.07M12 6.375a3.375 3.375 0 1 1-6.75 0 3.375 3.375 0 0 1 6.75 0Zm8.25 2.25a2.625 2.625 0 1 1-5.25 0 2.625 2.625 0 0 1 5.25 0Z"
|
|
/>
|
|
</svg>
|
|
),
|
|
},
|
|
{
|
|
label: "Profile",
|
|
href: "/profile",
|
|
icon: (
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
viewBox="0 0 24 24"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
strokeWidth={1.5}
|
|
className="size-5"
|
|
>
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z"
|
|
/>
|
|
</svg>
|
|
),
|
|
},
|
|
];
|
|
|
|
export function Sidebar({
|
|
displayName,
|
|
email,
|
|
avatarUrl,
|
|
}: {
|
|
displayName: string;
|
|
email: string;
|
|
avatarUrl: string;
|
|
}) {
|
|
const pathname = usePathname();
|
|
return (
|
|
<aside className="flex w-64 flex-col border-r border-neutral-200 bg-white">
|
|
{/* Brand */}
|
|
<div className="flex h-16 items-center gap-2 border-b border-neutral-200 px-6">
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
viewBox="0 0 24 24"
|
|
fill="currentColor"
|
|
className="size-6 text-neutral-900"
|
|
>
|
|
<path
|
|
fillRule="evenodd"
|
|
d="M4.848 2.771A49.144 49.144 0 0 1 12 2.25c2.43 0 4.817.178 7.152.52 1.978.292 3.348 2.024 3.348 3.97v6.02c0 1.946-1.37 3.678-3.348 3.97a48.901 48.901 0 0 1-3.476.383.39.39 0 0 0-.297.17l-2.755 4.133a.75.75 0 0 1-1.248 0l-2.755-4.133a.39.39 0 0 0-.297-.17 48.9 48.9 0 0 1-3.476-.384c-1.978-.29-3.348-2.024-3.348-3.97V6.741c0-1.946 1.37-3.68 3.348-3.97ZM6.75 8.25a.75.75 0 0 1 .75-.75h9a.75.75 0 0 1 0 1.5h-9a.75.75 0 0 1-.75-.75Zm.75 2.25a.75.75 0 0 0 0 1.5H12a.75.75 0 0 0 0-1.5H7.5Z"
|
|
clipRule="evenodd"
|
|
/>
|
|
</svg>
|
|
<span className="text-lg font-semibold tracking-tight">Fastchat</span>
|
|
</div>
|
|
|
|
{/* Navigation */}
|
|
<nav aria-label="Main navigation" className="flex-1 space-y-1 px-3 py-4">
|
|
{navItems.map((item) => {
|
|
const active = pathname === item.href;
|
|
return (
|
|
<Link
|
|
key={item.href}
|
|
href={item.href}
|
|
className={`flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium transition-colors ${
|
|
active
|
|
? "bg-neutral-100 text-neutral-900"
|
|
: "text-neutral-600 hover:bg-neutral-50 hover:text-neutral-900"
|
|
}`}
|
|
>
|
|
{item.icon}
|
|
{item.label}
|
|
</Link>
|
|
);
|
|
})}
|
|
</nav>
|
|
|
|
{/* User section */}
|
|
<div className="border-t border-neutral-200 p-4">
|
|
<div className="flex items-center gap-3">
|
|
<div className="flex size-9 items-center justify-center rounded-full bg-neutral-900 text-sm font-medium text-white">
|
|
<Image
|
|
src={avatarUrl}
|
|
alt=""
|
|
width={200}
|
|
height={200}
|
|
className="size-9 rounded-full object-cover"
|
|
/>
|
|
</div>
|
|
<div className="min-w-0 flex-1">
|
|
<p className="truncate text-sm font-medium text-neutral-900">
|
|
{displayName}
|
|
</p>
|
|
<p className="truncate text-xs text-neutral-500">{email}</p>
|
|
</div>
|
|
</div>
|
|
<form action={signOut}>
|
|
<button
|
|
type="submit"
|
|
className="mt-3 flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-neutral-600 transition-colors hover:bg-neutral-50 hover:text-neutral-900"
|
|
>
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
viewBox="0 0 24 24"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
strokeWidth={1.5}
|
|
className="size-4"
|
|
>
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
d="M15.75 9V5.25A2.25 2.25 0 0 0 13.5 3h-6a2.25 2.25 0 0 0-2.25 2.25v13.5A2.25 2.25 0 0 0 7.5 21h6a2.25 2.25 0 0 0 2.25-2.25V15m3 0 3-3m0 0-3-3m3 3H9"
|
|
/>
|
|
</svg>
|
|
Sign out
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</aside>
|
|
);
|
|
}
|