chore: Cleanup unused vars, exports, types * Cleanup some unused exports * Remove more * Readd CampaignPageIncludedHotelsRef * Add alias comment to procedure exports * Remove unused exports Approved-by: Linus Flood
35 lines
976 B
TypeScript
35 lines
976 B
TypeScript
import "server-only"
|
|
|
|
import { headers } from "next/headers"
|
|
|
|
import { webviews } from "@/constants/routes/webviews"
|
|
|
|
import type { Lang } from "@scandic-hotels/common/constants/language"
|
|
|
|
async function webviewSearchParams() {
|
|
const searchParams = new URLSearchParams()
|
|
const headersList = await headers()
|
|
const loginType = headersList.get("loginType")
|
|
if (loginType) {
|
|
searchParams.set("loginType", loginType)
|
|
}
|
|
|
|
const adobeMc = headersList.get("adobe_mc")
|
|
if (adobeMc) {
|
|
searchParams.set("adobe_mc", adobeMc)
|
|
}
|
|
return searchParams
|
|
}
|
|
|
|
export async function modWebviewLink(url: string, lang: Lang) {
|
|
const searchParams = await webviewSearchParams()
|
|
const urlWithoutLang = url.replace(`/${lang}`, "")
|
|
|
|
const webviewUrl = `/${lang}/webview${urlWithoutLang}`
|
|
if (webviews.includes(webviewUrl) || url.startsWith("/webview")) {
|
|
return `${webviewUrl}?${searchParams.toString()}`
|
|
} else {
|
|
return `${url}?${searchParams.toString()}`
|
|
}
|
|
}
|