50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
"use client"
|
|
|
|
import { PropsWithChildren } 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]
|
|
|
|
return (
|
|
<Link
|
|
className={className}
|
|
id={trackingId}
|
|
color={color}
|
|
href={href}
|
|
prefetch={false}
|
|
variant={variant}
|
|
onClick={() => trackLoginClick(position)}
|
|
>
|
|
{children}
|
|
</Link>
|
|
)
|
|
}
|