pollo/app/components/Header.tsx

60 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-08-27 23:57:17 -06:00
"use client";
2023-11-21 16:05:53 -07:00
import { UserButton, useUser } from "@clerk/remix";
import { Link, useLocation, useNavigate } from "@remix-run/react";
2023-04-20 04:20:00 -06:00
interface NavbarProps {
title: string;
}
2023-08-08 22:36:43 -06:00
const Navbar = ({ title }: NavbarProps) => {
2023-09-01 23:32:24 -06:00
const { isSignedIn } = useUser();
2023-11-21 16:05:53 -07:00
const { pathname } = useLocation();
const navigate = useNavigate();
const navigationMenu = () => {
2023-08-27 23:57:17 -06:00
if (pathname !== "/dashboard" && isSignedIn) {
return (
2023-11-21 16:05:53 -07:00
<Link className="btn btn-primary btn-outline mx-2" to="/dashboard">
2023-09-25 00:00:43 -06:00
Dashboard
</Link>
);
2023-08-12 17:12:42 -06:00
} else if (!isSignedIn) {
return (
2023-08-12 17:12:42 -06:00
<button
2023-09-01 20:38:27 -06:00
className="btn btn-primary"
2023-11-21 16:05:53 -07:00
onClick={() => void navigate("/sign-in")}
2023-08-12 17:12:42 -06:00
>
2023-09-25 00:00:43 -06:00
Sign In
</button>
);
}
};
2023-04-20 04:20:00 -06:00
return (
<nav className="navbar bg-base-100 h-12">
2023-04-20 04:20:00 -06:00
<div className="flex-1">
<Link
about="Back to home."
2023-11-21 16:05:53 -07:00
to="/"
2023-04-20 04:20:00 -06:00
className="btn btn-ghost normal-case text-xl"
>
2023-11-19 16:50:29 -07:00
<img
className="md:mr-2"
2023-04-20 04:20:00 -06:00
src="/logo.webp"
alt="Nav Logo"
2023-07-25 12:40:00 -06:00
width={32}
height={32}
2023-04-20 04:20:00 -06:00
/>
2023-11-21 09:05:09 -07:00
<span className="hidden md:inline-flex">{title}</span>
2023-04-20 04:20:00 -06:00
</Link>
</div>
2023-09-01 23:32:24 -06:00
{navigationMenu()}
2023-09-01 23:37:51 -06:00
<UserButton afterSignOutUrl="/" userProfileMode="modal" />
2023-04-20 04:20:00 -06:00
</nav>
);
};
export default Navbar;