feat: add env var for signup flow

This commit is contained in:
Chuma McPhoy
2024-11-04 15:55:49 +01:00
parent 452ad7bcd4
commit fd6c15ed78
4 changed files with 31 additions and 3 deletions

View File

@@ -51,5 +51,6 @@ GOOGLE_STATIC_MAP_SIGNATURE_SECRET=""
GOOGLE_STATIC_MAP_ID=""
GOOGLE_DYNAMIC_MAP_ID=""
HIDE_FOR_NEXT_RELEASE="true"
HIDE_FOR_NEXT_RELEASE="false"
SHOW_SIGNUP_FLOW="true"
USE_NEW_REWARDS_ENDPOINT="true"

View File

@@ -1,5 +1,7 @@
import { headers } from "next/headers"
import { notFound } from "next/navigation"
import { isSignupPage } from "@/constants/routes/signup"
import { env } from "@/env/server"
import HotelPage from "@/components/ContentType/HotelPage"
@@ -22,17 +24,24 @@ export default function ContentTypePage({
}: PageArgs<LangParams & ContentTypeParams & UIDParams, {}>) {
setLang(params.lang)
const pathname = headers().get("x-pathname") || ""
const isSignupRoute = isSignupPage(pathname)
switch (params.contentType) {
case "collection-page":
if (env.HIDE_FOR_NEXT_RELEASE) {
return notFound()
}
return <CollectionPage />
case "content-page":
if (env.HIDE_FOR_NEXT_RELEASE) {
case "content-page": {
if (!isSignupRoute && env.HIDE_FOR_NEXT_RELEASE) {
return notFound()
}
if (isSignupRoute && !env.SHOW_SIGNUP_FLOW) {
return notFound()
}
return <ContentPage />
}
case "loyalty-page":
return <LoyaltyPage />
case "hotel-page":

View File

@@ -17,3 +17,13 @@ export const signupVerify: LangRoute = {
da: `${signup.da}/bekraeft`,
de: `${signup.de}/verifizieren`,
}
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
}

8
env/server.ts vendored
View File

@@ -60,6 +60,13 @@ export const env = createEnv({
SEAMLESS_LOGOUT_FI: z.string(),
SEAMLESS_LOGOUT_NO: z.string(),
SEAMLESS_LOGOUT_SV: z.string(),
SHOW_SIGNUP_FLOW: z
.string()
// only allow "true" or "false"
.refine((s) => s === "true" || s === "false")
// transform to boolean
.transform((s) => s === "true")
.default("false"),
WEBVIEW_ENCRYPTION_KEY: z.string(),
BOOKING_ENCRYPTION_KEY: z.string(),
GOOGLE_STATIC_MAP_KEY: z.string(),
@@ -125,6 +132,7 @@ export const env = createEnv({
SEAMLESS_LOGOUT_FI: process.env.SEAMLESS_LOGOUT_FI,
SEAMLESS_LOGOUT_NO: process.env.SEAMLESS_LOGOUT_NO,
SEAMLESS_LOGOUT_SV: process.env.SEAMLESS_LOGOUT_SV,
SHOW_SIGNUP_FLOW: process.env.SHOW_SIGNUP_FLOW,
WEBVIEW_ENCRYPTION_KEY: process.env.WEBVIEW_ENCRYPTION_KEY,
BOOKING_ENCRYPTION_KEY: process.env.BOOKING_ENCRYPTION_KEY,
GOOGLE_STATIC_MAP_KEY: process.env.GOOGLE_STATIC_MAP_KEY,