chore(SW-3381) Moved LoginButton to design system * chore(SW-3381) Moved LoginButton to design system Approved-by: Anton Gunnarsson
32 lines
691 B
TypeScript
32 lines
691 B
TypeScript
'use client'
|
|
|
|
import Link, { type LinkProps } from '../Link'
|
|
import { login } from '@scandic-hotels/common/constants/routes/handleAuth'
|
|
|
|
import type { PropsWithChildren } from 'react'
|
|
import type { Lang } from '@scandic-hotels/common/constants/language'
|
|
|
|
export function LoginButton({
|
|
lang,
|
|
pathName,
|
|
trackingId,
|
|
children,
|
|
...props
|
|
}: PropsWithChildren<
|
|
{
|
|
lang: Lang
|
|
pathName: string | null
|
|
trackingId: string
|
|
} & Omit<LinkProps, 'href'>
|
|
>) {
|
|
const href = pathName
|
|
? `${login[lang]}?redirectTo=${encodeURIComponent(pathName)}`
|
|
: login[lang]
|
|
|
|
return (
|
|
<Link id={trackingId} href={href} prefetch={false} {...props}>
|
|
{children}
|
|
</Link>
|
|
)
|
|
}
|