fix(SW-890): better feature flag handling

This commit is contained in:
Chuma McPhoy
2024-11-13 14:10:15 +01:00
parent fd6c15ed78
commit 5fef56cc97
2 changed files with 15 additions and 11 deletions

View File

@@ -25,7 +25,6 @@ export default function ContentTypePage({
setLang(params.lang)
const pathname = headers().get("x-pathname") || ""
const isSignupRoute = isSignupPage(pathname)
switch (params.contentType) {
case "collection-page":
@@ -34,12 +33,22 @@ export default function ContentTypePage({
}
return <CollectionPage />
case "content-page": {
if (!isSignupRoute && env.HIDE_FOR_NEXT_RELEASE) {
return notFound()
const isSignupRoute = isSignupPage(pathname)
if (env.HIDE_FOR_NEXT_RELEASE) {
// Hide content pages for next release for non-signup routes.
if (!isSignupRoute) {
return notFound()
}
}
if (isSignupRoute && !env.SHOW_SIGNUP_FLOW) {
return notFound()
if (!env.SHOW_SIGNUP_FLOW) {
// Hide content pages for signup routes when signup flow is disabled.
if (isSignupRoute) {
return notFound()
}
}
return <ContentPage />
}
case "loyalty-page":

View File

@@ -20,10 +20,5 @@ export const signupVerify: LangRoute = {
export function isSignupPage(path: string): boolean {
const signupPaths = [...Object.values(signup), ...Object.values(signupVerify)]
const result = signupPaths.some((signupPath) => {
const includes = signupPath.includes(path)
return includes
})
return result
return signupPaths.some((signupPath) => signupPath.includes(path))
}