aboutsummaryrefslogtreecommitdiff
path: root/apps/web/app/(dash)/header/header.tsx
blob: 9154ead8255e858b4efdd3bc4b3785d514e8c746 (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
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";

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">
        <Link className="" href="/home">
          <Image
            src={Logo}
            alt="SuperMemory logo"
            className="hover:brightness-125 duration-200"
          />
        </Link>

        <div className="flex items-center gap-2">
          <NewChatButton />

          <div className="relative group">
            <button className="flex duration-200 items-center text-[#7D8994] hover:bg-[#1F2429] text-[13px] gap-2 px-3 py-2 rounded-xl">
              History
            </button>

            <div className="absolute p-4 hidden group-hover:block right-0 w-full md:w-[400px] max-h-[70vh] overflow-auto">
              <div className="bg-[#1F2429] rounded-xl p-2 flex flex-col shadow-lg">
                {chatThreads.data.map((thread) => (
                  <Link
                    prefetch={false}
                    href={`/chat/${thread.id}`}
                    key={thread.id}
                    className="p-2 rounded-md hover:bg-secondary"
                  >
                    {thread.firstMessage}
                  </Link>
                ))}
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
}

export default Header;