import { Link, router } from '@inertiajs/react';

type WorkspaceLink = { label: string; href: string };

export default function WorkspaceHeader({
    links = [],
}: {
    links?: WorkspaceLink[];
}) {
    return (
        <header className="sticky top-0 z-40 border-b border-black/10 bg-[#f7f5ef]/95 px-4 py-3 backdrop-blur sm:px-8">
            <div className="mx-auto flex max-w-7xl items-center justify-between gap-4">
                <Link
                    href="/"
                    className="font-black tracking-tight text-[#171b1c]"
                >
                    racing<span className="text-[#cf3329]">.lk</span>
                    <span className="ml-2 hidden text-xs font-semibold tracking-[.18em] text-slate-500 uppercase sm:inline">
                        Workspace
                    </span>
                </Link>
                <nav
                    aria-label="Workspace navigation"
                    className="flex items-center gap-2 sm:gap-4"
                >
                    {links.map((link) => (
                        <Link
                            key={link.href}
                            href={link.href}
                            className="inline-flex rounded-lg px-2 py-2 text-xs font-bold whitespace-nowrap text-slate-700 transition hover:bg-white sm:px-3 sm:text-sm"
                        >
                            {link.label}
                        </Link>
                    ))}
                    <button
                        type="button"
                        onClick={() => router.post('/logout')}
                        className="rounded-lg border border-black/15 px-3 py-2 text-sm font-bold text-[#171b1c] hover:border-[#cf3329] hover:text-[#b72c24]"
                    >
                        Sign out
                    </button>
                </nav>
            </div>
        </header>
    );
}
