Files
web/apps/scandic-web/components/Current/LangPopup/index.tsx
Anton Gunnarsson 846fd904a6 Merged in feat/sw-2859-set-up-shared-trpc-package (pull request #2319)
feat(SW-2859): Create trpc package

* Add isEdge, safeTry and dataCache to new common package

* Add eslint and move prettier config

* Clean up tests

* Create trpc package and move initialization

* Move errors and a few procedures

* Move telemetry to common package

* Move tokenManager to common package

* Add Sentry to procedures

* Clean up procedures

* Fix self-referencing imports

* Add exports to packages and lint rule to prevent relative imports

* Add env to trpc package

* Add eslint to trpc package

* Apply lint rules

* Use direct imports from trpc package

* Add lint-staged config to trpc

* Move lang enum to common

* Restructure trpc package folder structure

* Fix lang imports


Approved-by: Linus Flood
2025-06-18 12:14:20 +00:00

100 lines
2.4 KiB
TypeScript

/* eslint-disable formatjs/no-literal-string-in-jsx */
import { headers } from "next/headers"
import { Lang } from "@scandic-hotels/common/constants/language"
import { localeToLang } from "@/constants/languages"
import { getLang } from "@/i18n/serverContext"
export default async function LangPopup() {
const headersList = await headers()
const preferedLang = headersList.get("Accept-Language") ?? ""
const possibleLangs = Object.keys(localeToLang)
if (!possibleLangs.includes(preferedLang)) {
return null
}
const langOfChoice: Lang = localeToLang[preferedLang as Lang]
const lang = await getLang()
if (langOfChoice === lang) {
return null
}
let language = ""
let viewIn = ""
switch (langOfChoice) {
case Lang.de:
language = "Deutsch"
viewIn = "Ansicht in"
break
case Lang.da:
language = "Dansk"
viewIn = "Se in"
break
case Lang.fi:
language = "Suomi"
viewIn = "Katso in"
break
case Lang.no:
language = "Norsk"
viewIn = "Se in"
break
case Lang.sv:
language = "Svenska"
viewIn = "Visa in"
break
}
return (
<div className="lang-popup hidden" id="lang-popup">
<a
href="#"
className="lang-popup__close"
title="Close language change popup"
>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
width="16px"
height="16px"
viewBox="0 0 16 16"
version="1.1"
style={{
stroke: "#757575",
width: "14px",
height: "14px",
display: "block",
strokeWidth: "2px",
}}
>
<title>Close</title>
<g id="web-close" fillRule="evenodd">
<line x1="0" y1="0" x2="100%" y2="100%" />
<line x1="0" y1="100%" x2="100%" y2="0" />
</g>
</svg>
</a>
<div className="lang-popup__body">
<p className="lang-popup__msg">
You are viewing our website in English, would you like to change to{" "}
{language}?
</p>
</div>
<div className="lang-popup__footer">
<a href="" className="lang-popup__cta btn btn--primary">
{viewIn} {language}
</a>
<a href="#" className="lang-popup__cancel btn btn--link">
No thanks
</a>
</div>
</div>
)
}