Files
encoach_ui_odoo19/src/components/Navbar.tsx

50 lines
1.9 KiB
TypeScript

import {User} from "@/interfaces/user";
import Link from "next/link";
import FocusLayer from "@/components/FocusLayer";
import {preventNavigation} from "@/utils/navigation.disabled";
import {useRouter} from "next/router";
import axios from "axios";
import {RiLogoutBoxFill} from "react-icons/ri";
import {BsPower} from "react-icons/bs";
interface Props {
user: User;
navDisabled?: boolean;
focusMode?: boolean;
onFocusLayerMouseEnter?: () => void;
}
/* eslint-disable @next/next/no-img-element */
export default function Navbar({user, navDisabled = false, focusMode = false, onFocusLayerMouseEnter}: Props) {
const disableNavigation = preventNavigation(navDisabled, focusMode);
const router = useRouter();
const logout = async () => {
axios.post("/api/logout").finally(() => {
setTimeout(() => router.reload(), 500);
});
};
return (
<header className="w-full bg-transparent py-4 -lg:justify-between lg:gap-12 flex items-center relative -lg:px-4">
<Link href={disableNavigation ? "" : "/"} className=" lg:px-8 flex gap-8 items-center">
<img src="/logo.png" alt="EnCoach's Logo" className="w-12" />
<h1 className="font-bold text-2xl w-1/6 -lg:hidden">EnCoach</h1>
</Link>
<div className="flex justify-between lg:w-5/6 lg:mr-8">
<input
type="text"
placeholder="Search..."
className="rounded-full py-4 px-6 border border-mti-gray-platinum outline-none -lg:hidden"
/>
<Link href={disableNavigation ? "" : "/profile"} className="flex gap-6 items-center justify-end">
<img src={user.profilePicture} alt={user.name} className="w-10 h-10 rounded-full object-cover" />
<span className="text-right -lg:hidden">{user.name}</span>
<BsPower size={40} className="bg-mti-red-light px-2 rounded-full text-white lg:hidden" />
</Link>
</div>
{focusMode && <FocusLayer onFocusLayerMouseEnter={onFocusLayerMouseEnter} />}
</header>
);
}