Merged in chore/SW-3381-move-loginbutton-to-ds- (pull request #2752)
chore(SW-3381) Moved LoginButton to design system * chore(SW-3381) Moved LoginButton to design system Approved-by: Anton Gunnarsson
This commit is contained in:
71
packages/common/constants/routes/handleAuth.ts
Normal file
71
packages/common/constants/routes/handleAuth.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* These are routes for login, logout, signup, etc.
|
||||
*/
|
||||
|
||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
||||
export const login = {
|
||||
da: "/da/log-pa",
|
||||
de: "/de/anmeldung",
|
||||
en: "/en/login",
|
||||
fi: "/fi/kirjaudu-sisaan",
|
||||
no: "/no/logg-inn",
|
||||
sv: "/sv/logga-in",
|
||||
}
|
||||
|
||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
||||
export const loginUnLocalized = {
|
||||
da: "/da/login",
|
||||
de: "/de/login",
|
||||
en: "/en/login",
|
||||
fi: "/fi/login",
|
||||
no: "/no/login",
|
||||
sv: "/sv/login",
|
||||
}
|
||||
|
||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
||||
export const logout = {
|
||||
da: "/da/log-ud",
|
||||
de: "/de/ausloggen",
|
||||
en: "/en/logout",
|
||||
fi: "/fi/kirjaudu-ulos",
|
||||
no: "/no/logg-ut",
|
||||
sv: "/sv/logga-ut",
|
||||
}
|
||||
|
||||
export const logoutSafely = {
|
||||
da: "/da/logoutSafely",
|
||||
de: "/de/logoutSafely",
|
||||
en: "/en/logoutSafely",
|
||||
fi: "/fi/logoutSafely",
|
||||
no: "/no/logoutSafely",
|
||||
sv: "/sv/logoutSafely",
|
||||
}
|
||||
|
||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
||||
export const logoutUnLocalized = {
|
||||
da: "/da/logout",
|
||||
de: "/de/logout",
|
||||
en: "/en/logout",
|
||||
fi: "/fi/logout",
|
||||
no: "/no/logout",
|
||||
sv: "/sv/logout",
|
||||
}
|
||||
|
||||
/** @type {import('@scandic-hotels/common/constants/routes/langRoute').LangRoute} */
|
||||
export const verifymagiclink = {
|
||||
da: "/da/verifymagiclink",
|
||||
de: "/de/verifymagiclink",
|
||||
en: "/en/verifymagiclink",
|
||||
fi: "/fi/verifymagiclink",
|
||||
no: "/no/verifymagiclink",
|
||||
sv: "/sv/verifymagiclink",
|
||||
}
|
||||
|
||||
export const handleAuth = [
|
||||
...Object.values(login),
|
||||
...Object.values(logout),
|
||||
...Object.values(verifymagiclink),
|
||||
...Object.values(loginUnLocalized),
|
||||
...Object.values(logoutUnLocalized),
|
||||
...Object.values(logoutSafely),
|
||||
]
|
||||
31
packages/design-system/lib/components/LoginButton/index.tsx
Normal file
31
packages/design-system/lib/components/LoginButton/index.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
'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>
|
||||
)
|
||||
}
|
||||
@@ -133,6 +133,7 @@
|
||||
"./Lightbox": "./lib/components/Lightbox/index.tsx",
|
||||
"./Link": "./lib/components/Link/index.tsx",
|
||||
"./LoadingSpinner": "./lib/components/LoadingSpinner/index.tsx",
|
||||
"./LoginButton": "./lib/components/LoginButton/index.tsx",
|
||||
"./Map/InteractiveMap": "./lib/components/Map/InteractiveMap/index.tsx",
|
||||
"./Map/mapConstants": "./lib/components/Map/mapConstants.ts",
|
||||
"./Map/Markers/HotelMarkerByType": "./lib/components/Map/Markers/HotelMarkerByType.tsx",
|
||||
|
||||
Reference in New Issue
Block a user