Merged in feat/sw-3580-redemption-feature-flag (pull request #3045)

feat(SW-3580): Add feature toggle enableRedemption to BookingFlowConfig

* Add feature toggle enableRedemption to BookingFlowConfig

* Update error message


Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2025-11-03 07:57:39 +00:00
parent b2398dba4a
commit 1eb70766b4
6 changed files with 22 additions and 0 deletions

View File

@@ -4,12 +4,15 @@ import { membershipTermsAndConditions } from "@scandic-hotels/common/constants/r
import { myStay } from "@scandic-hotels/common/constants/routes/myStay"
import { privacyPolicyRoutes } from "@scandic-hotels/common/constants/routes/privacyPolicyRoutes"
import { env } from "@/env/server"
import type { BookingFlowConfig } from "@scandic-hotels/booking-flow/BookingFlowConfig"
import type { Lang } from "@scandic-hotels/common/constants/language"
import type { LangRoute } from "@scandic-hotels/common/constants/routes/langRoute"
export const bookingFlowConfig: BookingFlowConfig = {
bookingCodeEnabled: false,
redemptionEnabled: env.REDEMPTION_ENABLED === true,
enterDetailsMembershipIdInputLocation: "join-card",
variant: "partner-sas",
routes: {

View File

@@ -30,6 +30,11 @@ export const env = createEnv({
IRON_SESSION_SECRET: z.string().min(32),
CURITY_ISSUER_USER: z.string(),
CURITY_CLIENT_SECRET_USER: z.string(),
REDEMPTION_ENABLED: z
.string()
.refine((s) => s === "true" || s === "false")
.transform((s) => s === "true")
.default("false"),
},
emptyStringAsUndefined: true,
runtimeEnv: {
@@ -44,5 +49,6 @@ export const env = createEnv({
SAS_AUTH_ENDPOINT: process.env.SAS_AUTH_ENDPOINT,
SENTRY_ENVIRONMENT: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
SENTRY_SERVER_SAMPLERATE: process.env.SENTRY_SERVER_SAMPLERATE,
REDEMPTION_ENABLED: process.env.REDEMPTION_ENABLED,
},
})

View File

@@ -8,6 +8,7 @@ import type { BookingFlowConfig } from "@scandic-hotels/booking-flow/BookingFlow
export const bookingFlowConfig: BookingFlowConfig = {
bookingCodeEnabled: true,
redemptionEnabled: true,
enterDetailsMembershipIdInputLocation: "form",
variant: "scandic",
routes: {

View File

@@ -10,6 +10,7 @@ import type { BookingFlowVariant } from "./bookingFlowVariants"
export type BookingFlowConfig = {
bookingCodeEnabled: boolean
redemptionEnabled: boolean
enterDetailsMembershipIdInputLocation: "form" | "join-card"
variant: BookingFlowVariant
routes: {

View File

@@ -79,6 +79,8 @@ export default function RewardNight() {
}
}, [resetOnMultiroomError, ref])
if (!config.redemptionEnabled) return null
return (
<div ref={ref} onBlur={(e) => closeOnBlur(e.nativeEvent)}>
<Checkbox

View File

@@ -3,6 +3,7 @@ import { notFound } from "next/navigation"
import { Suspense } from "react"
import { FamilyAndFriendsCodes } from "@scandic-hotels/common/constants/familyAndFriends"
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
import { BookingFlowConfig } from "../bookingFlowConfig/bookingFlowConfig"
import HotelHeader from "../components/EnterDetails/Header"
@@ -44,6 +45,14 @@ export async function EnterDetailsPage({
if (!booking) return notFound()
// This should never happen unless a user tampers with the URL
if (
!config.redemptionEnabled &&
booking.searchType === SEARCH_TYPE_REDEMPTION
) {
throw new Error("Redemptions are disabled")
}
if (selectRoomParams.has("activeRoomIndex")) {
selectRoomParams.delete("activeRoomIndex")
}