fix: add correct login button instead of sending everyone to my pages
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import { PropsWithChildren, useEffect } from "react"
|
||||
|
||||
import { login } from "@/constants/routes/handleAuth"
|
||||
|
||||
import Link from "@/components/TempDesignSystem/Link"
|
||||
import { LinkProps } from "@/components/TempDesignSystem/Link/link"
|
||||
import useLang from "@/hooks/useLang"
|
||||
import { useLazyPathname } from "@/hooks/useLazyPathname"
|
||||
import { trackLoginClick } from "@/utils/tracking"
|
||||
|
||||
import { TrackingPosition } from "@/types/components/tracking"
|
||||
|
||||
export default function LoginButton({
|
||||
className,
|
||||
position,
|
||||
trackingId,
|
||||
children,
|
||||
color = "black",
|
||||
variant = "default",
|
||||
}: PropsWithChildren<{
|
||||
className: string
|
||||
trackingId: string
|
||||
position: TrackingPosition
|
||||
color?: LinkProps["color"]
|
||||
variant?: "default" | "signupVerification"
|
||||
}>) {
|
||||
const lang = useLang()
|
||||
const pathName = useLazyPathname()
|
||||
|
||||
const href = pathName
|
||||
? `${login[lang]}?redirectTo=${encodeURIComponent(pathName)}`
|
||||
: login[lang]
|
||||
|
||||
useEffect(() => {
|
||||
document
|
||||
.getElementById(trackingId)
|
||||
?.addEventListener("click", () => trackLoginClick(position))
|
||||
return () => {
|
||||
document
|
||||
.getElementById(trackingId)
|
||||
?.removeEventListener("click", () => trackLoginClick(position))
|
||||
}
|
||||
}, [position, trackingId])
|
||||
|
||||
return (
|
||||
<Link
|
||||
className={className}
|
||||
id={trackingId}
|
||||
color={color}
|
||||
href={href}
|
||||
prefetch={false}
|
||||
variant={variant}
|
||||
>
|
||||
{children}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
@@ -7,13 +7,13 @@ import { myPages } from "@/constants/routes/myPages"
|
||||
import useDropdownStore from "@/stores/main-menu"
|
||||
|
||||
import Image from "@/components/Image"
|
||||
import LoginButton from "@/components/LoginButton"
|
||||
import Avatar from "@/components/MyPages/Avatar"
|
||||
import Link from "@/components/TempDesignSystem/Link"
|
||||
import useLang from "@/hooks/useLang"
|
||||
import { trackClick } from "@/utils/tracking"
|
||||
|
||||
import BookingButton from "../BookingButton"
|
||||
import LoginButton from "../LoginButton"
|
||||
|
||||
import styles from "./mainMenu.module.css"
|
||||
|
||||
|
||||
@@ -2,12 +2,11 @@ import { logout } from "@/constants/routes/handleAuth"
|
||||
import { overview } from "@/constants/routes/myPages"
|
||||
import { getName } from "@/lib/trpc/memoizedRequests"
|
||||
|
||||
import LoginButton from "@/components/LoginButton"
|
||||
import Link from "@/components/TempDesignSystem/Link"
|
||||
import { getIntl } from "@/i18n"
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
|
||||
import LoginButton from "../LoginButton"
|
||||
|
||||
import styles from "./topMenu.module.css"
|
||||
|
||||
import type { TopMenuProps } from "@/types/components/current/header/topMenu"
|
||||
@@ -67,7 +66,7 @@ export default async function TopMenu({
|
||||
) : (
|
||||
<LoginButton
|
||||
position="hamburger menu"
|
||||
trackingId="loginStartTopMeny"
|
||||
trackingId="loginStartTopMenu"
|
||||
className={`${styles.sessionLink} ${styles.loginLink}`}
|
||||
>
|
||||
{formatMessage({ id: "Log in" })}
|
||||
|
||||
Reference in New Issue
Block a user