Foxnouns.NET/Foxnouns.Frontend/app/components/nav/Navbar.tsx

36 lines
1 KiB
TypeScript
Raw Normal View History

import { Link, useFetcher } from "@remix-run/react";
import Meta from "~/lib/api/meta";
import { User } from "~/lib/api/user";
import { Nav, NavDropdown } from "react-bootstrap";
2024-09-10 20:33:22 +02:00
import { useTranslation } from "react-i18next";
import BaseNavbar from "~/components/nav/BaseNavbar";
export default function MainNavbar({ user }: { meta: Meta; user?: User }) {
const fetcher = useFetcher();
2024-09-10 20:33:22 +02:00
const { t } = useTranslation();
const userMenu = user ? (
<NavDropdown title={<>@{user.username}</>} align="end">
<NavDropdown.Item as={Link} to={`/@${user.username}`}>
2024-09-10 20:33:22 +02:00
{t("navbar.view-profile")}
</NavDropdown.Item>
<NavDropdown.Item as={Link} to="/settings">
2024-09-10 20:33:22 +02:00
{t("navbar.settings")}
</NavDropdown.Item>
<NavDropdown.Divider />
2024-09-10 20:33:22 +02:00
<fetcher.Form method="POST" action="/auth/log-out">
<NavDropdown.Item as="button" type="submit">
{t("navbar.log-out")}
</NavDropdown.Item>
</fetcher.Form>
</NavDropdown>
) : (
2024-09-10 21:24:40 +02:00
<Nav.Link to="/auth/log-in" as={Link}>
2024-09-10 20:33:22 +02:00
{t("navbar.log-in")}
</Nav.Link>
);
return <BaseNavbar>{userMenu}</BaseNavbar>;
}