"use client";

import * as React from "react";
import { Building2, Plus } from "lucide-react";
import Link from "next/link";

import { ModeToggle } from "@/components/mode-toggle";
import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import { SidebarTrigger } from "@/components/ui/sidebar";

import type { ShellCompany } from "@/app/(dashboard)/dashboard-shell";

export function SiteHeader({ company }: { company?: ShellCompany }) {
  const showNewJobCta = company?.kind === "clinic";

  return (
    <header className="flex h-(--header-height) shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-(--header-height)">
      <div className="flex w-full items-center gap-1 px-4 py-3 lg:gap-2 lg:px-6">
        <SidebarTrigger className="-ml-1" />
        <Separator
          orientation="vertical"
          className="mx-2 data-[orientation=vertical]:h-4"
        />

        {company && (
          <div className="text-muted-foreground hidden items-center gap-1.5 text-sm md:flex">
            <Building2 className="size-3.5" />
            <span className="max-w-[260px] truncate">{company.name}</span>
          </div>
        )}

        <div className="ml-auto flex items-center gap-2">
          {showNewJobCta && (
            <Button asChild size="sm">
              <Link href="/jobs/new">
                <Plus className="size-4" />
                Yeni İş Yayınla
              </Link>
            </Button>
          )}
          <ModeToggle />
        </div>
      </div>
    </header>
  );
}
