header button logic
This commit is contained in:
parent
745d58ab3a
commit
040ee2dd05
|
|
@ -4,11 +4,24 @@ import { Button } from "@/components/ui/button";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { User, Menu } from "lucide-react";
|
import { User, Menu } from "lucide-react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
import AuthDialog from "@/components/layout/AuthDialog";
|
import AuthDialog from "@/components/layout/AuthDialog";
|
||||||
import useAuthPopup from "@/stores/useAuthPopup";
|
import useAuthPopup from "@/stores/useAuthPopup";
|
||||||
|
import useAuthStore from "@/stores/useAuthStore";
|
||||||
|
|
||||||
export default function Header() {
|
export default function Header() {
|
||||||
const authPopup = useAuthPopup();
|
const authPopup = useAuthPopup();
|
||||||
|
const router = useRouter();
|
||||||
|
const authStore = useAuthStore();
|
||||||
|
|
||||||
|
const handleProfileClick = () => {
|
||||||
|
const token = authStore.getToken();
|
||||||
|
if (token) {
|
||||||
|
router.push("/profile/reservations");
|
||||||
|
} else {
|
||||||
|
authPopup.open();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="sticky top-0 z-50 bg-white/95 backdrop-blur-sm border-b border-gray-100">
|
<header className="sticky top-0 z-50 bg-white/95 backdrop-blur-sm border-b border-gray-100">
|
||||||
|
|
@ -36,7 +49,7 @@ export default function Header() {
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
onClick={authPopup.open}
|
onClick={handleProfileClick}
|
||||||
className="text-gray-700 w-[100px] h-[48px] border"
|
className="text-gray-700 w-[100px] h-[48px] border"
|
||||||
>
|
>
|
||||||
<Menu className="!h-[24px] !w-[24px]" />
|
<Menu className="!h-[24px] !w-[24px]" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue