2023-05-27 17:42:48 +03:00
|
|
|
"use client";
|
2023-05-27 01:12:57 +03:00
|
|
|
import { useSupabase } from "@/app/supabase-provider";
|
2023-05-24 09:20:55 +03:00
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
import Link from "next/link";
|
2023-05-26 11:57:29 +03:00
|
|
|
import { Dispatch, FC, HTMLAttributes, ReactNode, SetStateAction } from "react";
|
2023-05-24 09:20:55 +03:00
|
|
|
import Button from "../ui/Button";
|
2023-05-27 01:12:57 +03:00
|
|
|
import DarkModeToggle from "./DarkModeToggle";
|
2023-05-24 09:20:55 +03:00
|
|
|
|
2023-05-26 11:57:29 +03:00
|
|
|
interface NavItemsProps extends HTMLAttributes<HTMLUListElement> {
|
|
|
|
setOpen?: Dispatch<SetStateAction<boolean>>;
|
|
|
|
}
|
2023-05-24 09:20:55 +03:00
|
|
|
|
2023-05-26 11:57:29 +03:00
|
|
|
const NavItems: FC<NavItemsProps> = ({ className, setOpen, ...props }) => {
|
2023-05-27 01:12:57 +03:00
|
|
|
const { session } = useSupabase();
|
|
|
|
const isUserLoggedIn = session?.user !== undefined;
|
2023-05-27 17:42:48 +03:00
|
|
|
const isLocal = process.env.NEXT_PUBLIC_ENV === "local";
|
2023-05-24 09:20:55 +03:00
|
|
|
return (
|
|
|
|
<ul
|
|
|
|
className={cn(
|
|
|
|
"flex flex-row items-center gap-4 text-sm flex-1",
|
|
|
|
className
|
|
|
|
)}
|
|
|
|
{...props}
|
|
|
|
>
|
2023-05-27 17:42:48 +03:00
|
|
|
{isLocal ? (
|
2023-05-24 09:20:55 +03:00
|
|
|
<>
|
2023-05-26 11:57:29 +03:00
|
|
|
<NavLink setOpen={setOpen} to="/upload">
|
|
|
|
Upload
|
|
|
|
</NavLink>
|
|
|
|
<NavLink setOpen={setOpen} to="/chat">
|
|
|
|
Chat
|
|
|
|
</NavLink>
|
|
|
|
<NavLink setOpen={setOpen} to="/explore">
|
|
|
|
Explore
|
|
|
|
</NavLink>
|
2023-05-24 09:20:55 +03:00
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<>
|
2023-05-26 11:57:29 +03:00
|
|
|
<NavLink setOpen={setOpen} to="https://github.com/StanGirard/quivr">
|
|
|
|
Github
|
|
|
|
</NavLink>
|
|
|
|
<NavLink setOpen={setOpen} to="https://discord.gg/HUpRgp2HG8">
|
|
|
|
Discord
|
|
|
|
</NavLink>
|
2023-05-24 09:20:55 +03:00
|
|
|
</>
|
|
|
|
)}
|
|
|
|
<div className="flex sm:flex-1 sm:justify-end flex-col items-center justify-center sm:flex-row gap-5 sm:gap-2">
|
2023-05-27 01:12:57 +03:00
|
|
|
{isUserLoggedIn && (
|
|
|
|
<Link href={"/logout"}>
|
|
|
|
<Button variant={"secondary"}>Logout</Button>
|
|
|
|
</Link>
|
|
|
|
)}
|
2023-05-27 17:42:48 +03:00
|
|
|
{!isLocal && (
|
|
|
|
<Link href={"https://try-quivr.streamlit.app"}>
|
|
|
|
<Button variant={"secondary"}>Try Demo</Button>
|
|
|
|
</Link>
|
|
|
|
)}
|
|
|
|
<DarkModeToggle />
|
2023-05-24 09:20:55 +03:00
|
|
|
</div>
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
interface NavLinkProps {
|
|
|
|
children: ReactNode;
|
|
|
|
to: string;
|
2023-05-26 11:57:29 +03:00
|
|
|
setOpen?: Dispatch<SetStateAction<boolean>>;
|
2023-05-24 09:20:55 +03:00
|
|
|
}
|
|
|
|
|
2023-05-26 11:57:29 +03:00
|
|
|
const NavLink: FC<NavLinkProps> = ({ children, to, setOpen }) => {
|
2023-05-24 09:20:55 +03:00
|
|
|
return (
|
|
|
|
<li className="group relative">
|
2023-05-26 11:57:29 +03:00
|
|
|
<Link onClick={() => setOpen && setOpen(false)} href={to}>
|
|
|
|
{children}
|
|
|
|
</Link>
|
2023-05-24 09:20:55 +03:00
|
|
|
<hr className="aboslute top-full border border-transparent border-b-primary dark:border-b-white scale-x-0 group-hover:scale-x-100 group-focus-within:scale-x-100 transition-transform" />
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default NavItems;
|