2025-09-21 11:02:31 -07:00
|
|
|
"use client";
|
2024-11-05 14:16:27 +03:00
|
|
|
|
2026-03-20 09:37:02 +00:00
|
|
|
import { PanelLeftIcon } from "lucide-react";
|
2025-09-21 11:02:31 -07:00
|
|
|
import Link from "next/link";
|
|
|
|
|
import { memo } from "react";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
2026-03-20 09:37:02 +00:00
|
|
|
import { useSidebar } from "@/components/ui/sidebar";
|
2026-03-13 20:30:52 -07:00
|
|
|
import { VercelIcon } from "./icons";
|
2025-09-21 11:02:31 -07:00
|
|
|
import { VisibilitySelector, type VisibilityType } from "./visibility-selector";
|
2024-10-31 15:39:07 +05:30
|
|
|
|
2024-12-06 13:36:56 +03:00
|
|
|
function PureChatHeader({
|
|
|
|
|
chatId,
|
|
|
|
|
selectedVisibilityType,
|
|
|
|
|
isReadonly,
|
|
|
|
|
}: {
|
|
|
|
|
chatId: string;
|
|
|
|
|
selectedVisibilityType: VisibilityType;
|
|
|
|
|
isReadonly: boolean;
|
|
|
|
|
}) {
|
2026-03-20 09:37:02 +00:00
|
|
|
const { state, toggleSidebar, isMobile } = useSidebar();
|
|
|
|
|
|
|
|
|
|
if (state === "collapsed" && !isMobile) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-24 16:35:51 -04:00
|
|
|
return (
|
2026-03-20 09:37:02 +00:00
|
|
|
<header className="sticky top-0 flex h-14 items-center gap-2 bg-sidebar px-3">
|
|
|
|
|
<Button
|
|
|
|
|
className="md:hidden"
|
|
|
|
|
onClick={toggleSidebar}
|
|
|
|
|
size="icon-sm"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
>
|
|
|
|
|
<PanelLeftIcon className="size-4" />
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
<Link
|
|
|
|
|
className="flex size-8 items-center justify-center rounded-lg md:hidden"
|
|
|
|
|
href="https://vercel.com/templates/next.js/chatbot"
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
<VercelIcon size={14} />
|
|
|
|
|
</Link>
|
|
|
|
|
|
2024-12-06 13:36:56 +03:00
|
|
|
{!isReadonly && (
|
|
|
|
|
<VisibilitySelector
|
|
|
|
|
chatId={chatId}
|
2025-09-21 11:02:31 -07:00
|
|
|
selectedVisibilityType={selectedVisibilityType}
|
2024-12-06 13:36:56 +03:00
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
2024-11-05 14:16:27 +03:00
|
|
|
<Button
|
2025-09-21 12:03:29 +01:00
|
|
|
asChild
|
2026-03-20 09:37:02 +00:00
|
|
|
className="hidden rounded-lg bg-foreground px-4 text-background hover:bg-foreground/90 md:ml-auto md:flex"
|
2024-11-05 14:16:27 +03:00
|
|
|
>
|
|
|
|
|
<Link
|
2026-03-20 09:37:02 +00:00
|
|
|
href="https://vercel.com/templates/next.js/chatbot"
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
target="_blank"
|
2024-11-05 14:16:27 +03:00
|
|
|
>
|
|
|
|
|
<VercelIcon size={16} />
|
|
|
|
|
Deploy with Vercel
|
|
|
|
|
</Link>
|
|
|
|
|
</Button>
|
2024-10-24 16:35:51 -04:00
|
|
|
</header>
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-12-03 17:49:38 +03:00
|
|
|
|
|
|
|
|
export const ChatHeader = memo(PureChatHeader, (prevProps, nextProps) => {
|
2025-09-01 11:07:07 +01:00
|
|
|
return (
|
|
|
|
|
prevProps.chatId === nextProps.chatId &&
|
|
|
|
|
prevProps.selectedVisibilityType === nextProps.selectedVisibilityType &&
|
|
|
|
|
prevProps.isReadonly === nextProps.isReadonly
|
|
|
|
|
);
|
2024-12-03 17:49:38 +03:00
|
|
|
});
|