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:
@@ -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: {
|
||||
|
||||
6
apps/partner-sas/env/server.ts
vendored
6
apps/partner-sas/env/server.ts
vendored
@@ -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,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -10,6 +10,7 @@ import type { BookingFlowVariant } from "./bookingFlowVariants"
|
||||
|
||||
export type BookingFlowConfig = {
|
||||
bookingCodeEnabled: boolean
|
||||
redemptionEnabled: boolean
|
||||
enterDetailsMembershipIdInputLocation: "form" | "join-card"
|
||||
variant: BookingFlowVariant
|
||||
routes: {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user