Merged in fix/LOY-483-only-english (pull request #3194)
Fix/LOY-483: Fix My Pages working in all languages * fix(LOY-483): add back specific handling of profile pages * fix(LOY-483): remove limit of 1 profiling consent config Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
@@ -3,6 +3,9 @@ import { type NextMiddleware, NextResponse } from "next/server"
|
|||||||
import {
|
import {
|
||||||
myPages,
|
myPages,
|
||||||
overview,
|
overview,
|
||||||
|
profile,
|
||||||
|
profileConsent,
|
||||||
|
profileEdit,
|
||||||
} from "@scandic-hotels/common/constants/routes/myPages"
|
} from "@scandic-hotels/common/constants/routes/myPages"
|
||||||
import { logger } from "@scandic-hotels/common/logger"
|
import { logger } from "@scandic-hotels/common/logger"
|
||||||
import { findLang } from "@scandic-hotels/common/utils/languages"
|
import { findLang } from "@scandic-hotels/common/utils/languages"
|
||||||
@@ -49,6 +52,32 @@ export const middleware: NextMiddleware = async (request) => {
|
|||||||
headers.set("x-uid", uid)
|
headers.set("x-uid", uid)
|
||||||
headers.set("x-contenttype", contentType)
|
headers.set("x-contenttype", contentType)
|
||||||
|
|
||||||
|
if (profile[lang].startsWith(nextUrl.pathname)) {
|
||||||
|
return NextResponse.rewrite(new URL(`/${lang}/my-pages/profile`, nextUrl), {
|
||||||
|
request: {
|
||||||
|
headers,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
} else if (profileEdit[lang].startsWith(nextUrl.pathname)) {
|
||||||
|
return NextResponse.rewrite(
|
||||||
|
new URL(`/${lang}/my-pages/profile/edit`, nextUrl),
|
||||||
|
{
|
||||||
|
request: {
|
||||||
|
headers,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else if (profileConsent[lang].startsWith(nextUrl.pathname)) {
|
||||||
|
return NextResponse.rewrite(
|
||||||
|
new URL(`/${lang}/my-pages/profile/consent`, nextUrl),
|
||||||
|
{
|
||||||
|
request: {
|
||||||
|
headers,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.next({
|
return NextResponse.next({
|
||||||
request: {
|
request: {
|
||||||
headers,
|
headers,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { gql } from "graphql-tag"
|
|||||||
|
|
||||||
export const GetProfilingConsent = gql`
|
export const GetProfilingConsent = gql`
|
||||||
query GetProfilingConsent($locale: String!) {
|
query GetProfilingConsent($locale: String!) {
|
||||||
all_profiling_consent(limit: 1, locale: $locale) {
|
all_profiling_consent(locale: $locale) {
|
||||||
items {
|
items {
|
||||||
main_icon
|
main_icon
|
||||||
profiling_consent_banner {
|
profiling_consent_banner {
|
||||||
|
|||||||
Reference in New Issue
Block a user