blob: eaade2582a9c077af2a5b97e3ee2ab3b929aeb5d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
import React from "react";
import Image from "next/image";
import Link from "next/link";
import Logo from "../../../public/logo.svg";
import { getChatHistory } from "../../actions/fetchers";
import NewChatButton from "./newChatButton";
import AutoBreadCrumbs from "./autoBreadCrumbs";
import SignOutButton from "./signOutButton";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@repo/ui/shadcn/dropdown-menu";
import { CaretDownIcon } from "@radix-ui/react-icons";
async function Header() {
const chatThreads = await getChatHistory();
if (!chatThreads.success || !chatThreads.data) {
return <div>Error fetching chat threads</div>;
}
return (
<div className="p-4 relative z-30 h-16 flex items-center">
<div className="w-full flex items-center justify-between">
<div className="flex items-center gap-4">
<Link className="" href="/home">
<Image
src={Logo}
alt="SuperMemory logo"
className="hover:brightness-125 duration-200 w-full h-full"
/>
</Link>
<AutoBreadCrumbs />
</div>
<div className="flex items-center gap-2">
<NewChatButton />
<DropdownMenu>
<DropdownMenuTrigger className="inline-flex flex-row flex-nowrap items-center text-muted-foreground hover:text-foreground">
History
<CaretDownIcon />
</DropdownMenuTrigger>
<DropdownMenuContent className="p-4 w-full md:w-[400px] max-h-[70vh] overflow-auto border-none">
{chatThreads.data.map((thread) => (
<DropdownMenuItem asChild>
<Link
prefetch={false}
href={`/chat/${thread.id}`}
key={thread.id}
className="p-2 rounded-md cursor-pointer focus:bg-secondary focus:text-current"
>
{thread.firstMessage}
</Link>
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
<SignOutButton />
</div>
</div>
</div>
);
}
export default Header;
|