Merged in feature/SW-3515-join-scandic-friends-placeholder (pull request #2883)
feat(SW-3515): display placeholder for join scandic friends * feat(SW-3515): display placeholder for join scandic friends * add missing variant config Approved-by: Linus Flood
This commit is contained in:
@@ -15,7 +15,6 @@ import { bookingTermsAndConditionsRoutes } from "@scandic-hotels/common/constant
|
|||||||
import { customerService } from "@scandic-hotels/common/constants/routes/customerService"
|
import { customerService } from "@scandic-hotels/common/constants/routes/customerService"
|
||||||
import { myStay } from "@scandic-hotels/common/constants/routes/myStay"
|
import { myStay } from "@scandic-hotels/common/constants/routes/myStay"
|
||||||
import { privacyPolicyRoutes } from "@scandic-hotels/common/constants/routes/privacyPolicyRoutes"
|
import { privacyPolicyRoutes } from "@scandic-hotels/common/constants/routes/privacyPolicyRoutes"
|
||||||
import { ScandicPartnersEnum } from "@scandic-hotels/common/constants/scandicPartners"
|
|
||||||
import { ToastHandler } from "@scandic-hotels/design-system/ToastHandler"
|
import { ToastHandler } from "@scandic-hotels/design-system/ToastHandler"
|
||||||
|
|
||||||
import AdobeSDKScript from "@/components/AdobeSDKScript"
|
import AdobeSDKScript from "@/components/AdobeSDKScript"
|
||||||
@@ -62,7 +61,7 @@ export default async function RootLayout(props: RootLayoutProps) {
|
|||||||
|
|
||||||
const bookingFlowConfig: BookingFlowConfig = {
|
const bookingFlowConfig: BookingFlowConfig = {
|
||||||
bookingCodeEnabled: false,
|
bookingCodeEnabled: false,
|
||||||
partner: ScandicPartnersEnum.sas,
|
variant: "partner-sas",
|
||||||
routes: {
|
routes: {
|
||||||
myStay: routeToScandicWeb(myStay),
|
myStay: routeToScandicWeb(myStay),
|
||||||
bookingTermsAndConditions: routeToScandicWeb(
|
bookingTermsAndConditions: routeToScandicWeb(
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import type { BookingFlowConfig } from "@scandic-hotels/booking-flow/BookingFlow
|
|||||||
|
|
||||||
export const bookingFlowConfig: BookingFlowConfig = {
|
export const bookingFlowConfig: BookingFlowConfig = {
|
||||||
bookingCodeEnabled: true,
|
bookingCodeEnabled: true,
|
||||||
|
variant: "scandic",
|
||||||
routes: {
|
routes: {
|
||||||
myStay,
|
myStay,
|
||||||
customerService,
|
customerService,
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ import { cache } from "react"
|
|||||||
import { BookingFlowConfigContextProvider } from "./bookingFlowConfigContext"
|
import { BookingFlowConfigContextProvider } from "./bookingFlowConfigContext"
|
||||||
|
|
||||||
import type { LangRoute } from "@scandic-hotels/common/constants/routes/langRoute"
|
import type { LangRoute } from "@scandic-hotels/common/constants/routes/langRoute"
|
||||||
import type { ScandicPartnersEnum } from "@scandic-hotels/common/constants/scandicPartners"
|
|
||||||
|
import type { BookingFlowVariant } from "./bookingFlowVariants"
|
||||||
|
|
||||||
export type BookingFlowConfig = {
|
export type BookingFlowConfig = {
|
||||||
bookingCodeEnabled: boolean
|
bookingCodeEnabled: boolean
|
||||||
partner?: ScandicPartnersEnum
|
variant: BookingFlowVariant
|
||||||
routes: {
|
routes: {
|
||||||
myStay: LangRoute
|
myStay: LangRoute
|
||||||
bookingTermsAndConditions: LangRoute
|
bookingTermsAndConditions: LangRoute
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
import { createContext, useContext } from "react"
|
import { createContext, useContext } from "react"
|
||||||
|
|
||||||
import type { ScandicPartnersEnum } from "@scandic-hotels/common/constants/scandicPartners"
|
|
||||||
|
|
||||||
import type { BookingFlowConfig } from "./bookingFlowConfig"
|
import type { BookingFlowConfig } from "./bookingFlowConfig"
|
||||||
|
import type { BookingFlowVariant } from "./bookingFlowVariants"
|
||||||
|
|
||||||
type BookingFlowConfigContextData = BookingFlowConfig
|
type BookingFlowConfigContextData = BookingFlowConfig
|
||||||
|
|
||||||
@@ -12,7 +11,7 @@ const BookingFlowConfigContext = createContext<
|
|||||||
BookingFlowConfigContextData | undefined
|
BookingFlowConfigContextData | undefined
|
||||||
>(undefined)
|
>(undefined)
|
||||||
|
|
||||||
export const useIsPartner = (partner: ScandicPartnersEnum) => {
|
export const useIsPartner = (variant: BookingFlowVariant) => {
|
||||||
const context = useContext(BookingFlowConfigContext)
|
const context = useContext(BookingFlowConfigContext)
|
||||||
|
|
||||||
if (!context) {
|
if (!context) {
|
||||||
@@ -21,7 +20,7 @@ export const useIsPartner = (partner: ScandicPartnersEnum) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return context.partner === partner
|
return context.variant === variant
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useBookingFlowConfig = (): BookingFlowConfigContextData => {
|
export const useBookingFlowConfig = (): BookingFlowConfigContextData => {
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export const bookingFlowVariants = ["scandic", "partner-sas"] as const
|
||||||
|
export type BookingFlowVariant = (typeof bookingFlowVariants)[number]
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { ScandicPartnersEnum } from "@scandic-hotels/common/constants/scandicPartners"
|
|
||||||
import { logger } from "@scandic-hotels/common/logger"
|
import { logger } from "@scandic-hotels/common/logger"
|
||||||
import { phoneErrors } from "@scandic-hotels/common/utils/zod/phoneValidator"
|
import { phoneErrors } from "@scandic-hotels/common/utils/zod/phoneValidator"
|
||||||
|
|
||||||
@@ -10,10 +9,12 @@ import {
|
|||||||
|
|
||||||
import type { IntlShape } from "react-intl"
|
import type { IntlShape } from "react-intl"
|
||||||
|
|
||||||
|
import type { BookingFlowVariant } from "../../bookingFlowConfig/bookingFlowVariants"
|
||||||
|
|
||||||
export function getErrorMessage(
|
export function getErrorMessage(
|
||||||
intl: IntlShape,
|
intl: IntlShape,
|
||||||
errorCode?: string,
|
variant: BookingFlowVariant,
|
||||||
partner?: ScandicPartnersEnum
|
errorCode?: string
|
||||||
) {
|
) {
|
||||||
switch (errorCode) {
|
switch (errorCode) {
|
||||||
case bookingWidgetErrors.BOOKING_CODE_INVALID:
|
case bookingWidgetErrors.BOOKING_CODE_INVALID:
|
||||||
@@ -47,7 +48,7 @@ export function getErrorMessage(
|
|||||||
"Multi-room booking is not available with this booking code.",
|
"Multi-room booking is not available with this booking code.",
|
||||||
})
|
})
|
||||||
case bookingWidgetErrors.MULTIROOM_REWARD_NIGHT_UNAVAILABLE:
|
case bookingWidgetErrors.MULTIROOM_REWARD_NIGHT_UNAVAILABLE:
|
||||||
return partner === ScandicPartnersEnum.sas
|
return variant === "partner-sas"
|
||||||
? intl.formatMessage({
|
? intl.formatMessage({
|
||||||
defaultMessage:
|
defaultMessage:
|
||||||
"Multi-room bookings are not available with EuroBonus points.",
|
"Multi-room bookings are not available with EuroBonus points.",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import Caption from "@scandic-hotels/design-system/Caption"
|
|||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
import { Input as InputWithLabel } from "@scandic-hotels/design-system/Input"
|
import { Input as InputWithLabel } from "@scandic-hotels/design-system/Input"
|
||||||
|
|
||||||
|
import { useBookingFlowConfig } from "../../bookingFlowConfig/bookingFlowConfigContext"
|
||||||
import { getErrorMessage } from "./errors"
|
import { getErrorMessage } from "./errors"
|
||||||
|
|
||||||
import styles from "./input.module.css"
|
import styles from "./input.module.css"
|
||||||
@@ -51,6 +52,7 @@ const BookingFlowInput = forwardRef<HTMLInputElement, InputProps>(
|
|||||||
) {
|
) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const { control } = useFormContext()
|
const { control } = useFormContext()
|
||||||
|
const config = useBookingFlowConfig()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Controller
|
<Controller
|
||||||
@@ -96,7 +98,11 @@ const BookingFlowInput = forwardRef<HTMLInputElement, InputProps>(
|
|||||||
{fieldState.error && !hideError ? (
|
{fieldState.error && !hideError ? (
|
||||||
<Caption className={styles.error} fontOnly>
|
<Caption className={styles.error} fontOnly>
|
||||||
<MaterialIcon icon="info" color="Icon/Feedback/Error" />
|
<MaterialIcon icon="info" color="Icon/Feedback/Error" />
|
||||||
{getErrorMessage(intl, fieldState.error.message)}
|
{getErrorMessage(
|
||||||
|
intl,
|
||||||
|
config.variant,
|
||||||
|
fieldState.error.message
|
||||||
|
)}
|
||||||
</Caption>
|
</Caption>
|
||||||
) : null}
|
) : null}
|
||||||
</TextField>
|
</TextField>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import Switch from "@scandic-hotels/design-system/Switch"
|
|||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||||
|
|
||||||
|
import { useBookingFlowConfig } from "../../../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||||
import BookingFlowInput from "../../../../BookingFlowInput"
|
import BookingFlowInput from "../../../../BookingFlowInput"
|
||||||
import { getErrorMessage } from "../../../../BookingFlowInput/errors"
|
import { getErrorMessage } from "../../../../BookingFlowInput/errors"
|
||||||
import { Input as BookingWidgetInput } from "../Input"
|
import { Input as BookingWidgetInput } from "../Input"
|
||||||
@@ -282,6 +283,7 @@ function BookingCodeError({
|
|||||||
}) {
|
}) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const isMultiroomError = isMultiRoomError(codeError.message)
|
const isMultiroomError = isMultiRoomError(codeError.message)
|
||||||
|
const config = useBookingFlowConfig()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.errorContainer}>
|
<div className={styles.errorContainer}>
|
||||||
@@ -296,7 +298,7 @@ function BookingCodeError({
|
|||||||
color="Icon/Feedback/Error"
|
color="Icon/Feedback/Error"
|
||||||
isFilled={!isDesktop}
|
isFilled={!isDesktop}
|
||||||
/>
|
/>
|
||||||
{getErrorMessage(intl, codeError.message)}
|
{getErrorMessage(intl, config.variant, codeError.message)}
|
||||||
</span>
|
</span>
|
||||||
</Typography>
|
</Typography>
|
||||||
{isMultiroomError ? (
|
{isMultiroomError ? (
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
import { useCallback, useEffect, useRef } from "react"
|
import { useCallback, useEffect, useRef } from "react"
|
||||||
import { useFormContext } from "react-hook-form"
|
import { useFormContext } from "react-hook-form"
|
||||||
import { useIntl } from "react-intl"
|
import { type IntlShape, useIntl } from "react-intl"
|
||||||
import { useMediaQuery } from "usehooks-ts"
|
import { useMediaQuery } from "usehooks-ts"
|
||||||
|
|
||||||
import { ScandicPartnersEnum } from "@scandic-hotels/common/constants/scandicPartners"
|
|
||||||
import Checkbox from "@scandic-hotels/design-system/Form/Checkbox"
|
import Checkbox from "@scandic-hotels/design-system/Form/Checkbox"
|
||||||
import { IconButton } from "@scandic-hotels/design-system/IconButton"
|
import { IconButton } from "@scandic-hotels/design-system/IconButton"
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
@@ -13,10 +12,9 @@ import Modal from "@scandic-hotels/design-system/Modal"
|
|||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||||
|
|
||||||
import {
|
import { type BookingFlowConfig } from "../../../../../bookingFlowConfig/bookingFlowConfig"
|
||||||
useBookingFlowConfig,
|
import { useBookingFlowConfig } from "../../../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||||
useIsPartner,
|
import { bookingFlowVariants } from "../../../../../bookingFlowConfig/bookingFlowVariants"
|
||||||
} from "../../../../../bookingFlowConfig/bookingFlowConfigContext"
|
|
||||||
import { getErrorMessage } from "../../../../BookingFlowInput/errors"
|
import { getErrorMessage } from "../../../../BookingFlowInput/errors"
|
||||||
import { RemoveExtraRooms } from "../RemoveExtraRooms/RemoveExtraRooms"
|
import { RemoveExtraRooms } from "../RemoveExtraRooms/RemoveExtraRooms"
|
||||||
import { isMultiRoomError } from "../utils"
|
import { isMultiRoomError } from "../utils"
|
||||||
@@ -28,7 +26,6 @@ import type { BookingWidgetSchema } from "../../../Client"
|
|||||||
export default function RewardNight() {
|
export default function RewardNight() {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const config = useBookingFlowConfig()
|
const config = useBookingFlowConfig()
|
||||||
const isPartnerSas = useIsPartner(ScandicPartnersEnum.sas)
|
|
||||||
const {
|
const {
|
||||||
setValue,
|
setValue,
|
||||||
getValues,
|
getValues,
|
||||||
@@ -36,22 +33,9 @@ export default function RewardNight() {
|
|||||||
trigger,
|
trigger,
|
||||||
} = useFormContext<BookingWidgetSchema>()
|
} = useFormContext<BookingWidgetSchema>()
|
||||||
const ref = useRef<HTMLDivElement | null>(null)
|
const ref = useRef<HTMLDivElement | null>(null)
|
||||||
const reward = isPartnerSas
|
const reward = getRewardMessage(config, intl)
|
||||||
? intl.formatMessage({
|
const rewardNightTooltip = getRewardNightTooltipMessage(config, intl)
|
||||||
defaultMessage: "EuroBonus Points",
|
|
||||||
})
|
|
||||||
: intl.formatMessage({
|
|
||||||
defaultMessage: "Reward Night",
|
|
||||||
})
|
|
||||||
const rewardNightTooltip = isPartnerSas
|
|
||||||
? intl.formatMessage({
|
|
||||||
defaultMessage:
|
|
||||||
"To book with EuroBonus points, make sure you're logged into your SAS EuroBonus account.",
|
|
||||||
})
|
|
||||||
: intl.formatMessage({
|
|
||||||
defaultMessage:
|
|
||||||
"To book a reward night, make sure you're logged in to your Scandic Friends account.",
|
|
||||||
})
|
|
||||||
const redemptionErr = errors[SEARCH_TYPE_REDEMPTION]
|
const redemptionErr = errors[SEARCH_TYPE_REDEMPTION]
|
||||||
const isDesktop = useMediaQuery("(min-width: 767px)")
|
const isDesktop = useMediaQuery("(min-width: 767px)")
|
||||||
|
|
||||||
@@ -149,7 +133,7 @@ export default function RewardNight() {
|
|||||||
className={styles.errorIcon}
|
className={styles.errorIcon}
|
||||||
isFilled={!isDesktop}
|
isFilled={!isDesktop}
|
||||||
/>
|
/>
|
||||||
{getErrorMessage(intl, redemptionErr.message, config.partner)}
|
{getErrorMessage(intl, config.variant, redemptionErr.message)}
|
||||||
</span>
|
</span>
|
||||||
</Typography>
|
</Typography>
|
||||||
{isMultiRoomError(redemptionErr.message) ? (
|
{isMultiRoomError(redemptionErr.message) ? (
|
||||||
@@ -162,3 +146,42 @@ export default function RewardNight() {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRewardMessage(config: BookingFlowConfig, intl: IntlShape): string {
|
||||||
|
if (!bookingFlowVariants.includes(config.variant)) {
|
||||||
|
throw new Error("Unknown booking flow variant")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (config.variant) {
|
||||||
|
case "partner-sas":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "EuroBonus Points",
|
||||||
|
})
|
||||||
|
case "scandic":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "Reward Night",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRewardNightTooltipMessage(
|
||||||
|
config: BookingFlowConfig,
|
||||||
|
intl: IntlShape
|
||||||
|
): string {
|
||||||
|
if (!bookingFlowVariants.includes(config.variant)) {
|
||||||
|
throw new Error("Unknown booking flow variant")
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (config.variant) {
|
||||||
|
case "partner-sas":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage:
|
||||||
|
"To book with EuroBonus points, make sure you're logged into your SAS EuroBonus account.",
|
||||||
|
})
|
||||||
|
case "scandic":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage:
|
||||||
|
"To book a reward night, make sure you're logged in to your Scandic Friends account.",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import CountrySelect from "@scandic-hotels/design-system/Form/Country"
|
|||||||
import Phone from "@scandic-hotels/design-system/Form/Phone"
|
import Phone from "@scandic-hotels/design-system/Form/Phone"
|
||||||
import { useFormTracking } from "@scandic-hotels/tracking/useFormTracking"
|
import { useFormTracking } from "@scandic-hotels/tracking/useFormTracking"
|
||||||
|
|
||||||
|
import { useBookingFlowConfig } from "../../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||||
import { useRoomContext } from "../../../../contexts/EnterDetails/RoomContext"
|
import { useRoomContext } from "../../../../contexts/EnterDetails/RoomContext"
|
||||||
import useLang from "../../../../hooks/useLang"
|
import useLang from "../../../../hooks/useLang"
|
||||||
import { getFormattedCountryList } from "../../../../misc/getFormatedCountryList"
|
import { getFormattedCountryList } from "../../../../misc/getFormatedCountryList"
|
||||||
@@ -29,6 +30,7 @@ const formID = "enter-details"
|
|||||||
export default function Details() {
|
export default function Details() {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
|
const config = useBookingFlowConfig()
|
||||||
|
|
||||||
const { addPreSubmitCallback, rooms } = useEnterDetailsStore((state) => ({
|
const { addPreSubmitCallback, rooms } = useEnterDetailsStore((state) => ({
|
||||||
addPreSubmitCallback: state.actions.addPreSubmitCallback,
|
addPreSubmitCallback: state.actions.addPreSubmitCallback,
|
||||||
@@ -205,7 +207,11 @@ export default function Details() {
|
|||||||
<CountrySelect
|
<CountrySelect
|
||||||
className={styles.fullWidth}
|
className={styles.fullWidth}
|
||||||
countries={getFormattedCountryList(intl)}
|
countries={getFormattedCountryList(intl)}
|
||||||
errorMessage={getErrorMessage(intl, errors.countryCode?.message)}
|
errorMessage={getErrorMessage(
|
||||||
|
intl,
|
||||||
|
config.variant,
|
||||||
|
errors.countryCode?.message
|
||||||
|
)}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
defaultMessage: "Country",
|
defaultMessage: "Country",
|
||||||
})}
|
})}
|
||||||
@@ -227,7 +233,11 @@ export default function Details() {
|
|||||||
})}
|
})}
|
||||||
countriesWithTranslatedName={getFormattedCountryList(intl)}
|
countriesWithTranslatedName={getFormattedCountryList(intl)}
|
||||||
defaultCountryCode={getDefaultCountryFromLang(lang)}
|
defaultCountryCode={getDefaultCountryFromLang(lang)}
|
||||||
errorMessage={getErrorMessage(intl, errors.phoneNumber?.message)}
|
errorMessage={getErrorMessage(
|
||||||
|
intl,
|
||||||
|
config.variant,
|
||||||
|
errors.phoneNumber?.message
|
||||||
|
)}
|
||||||
className={styles.fullWidth}
|
className={styles.fullWidth}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
defaultMessage: "Phone number",
|
defaultMessage: "Phone number",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import styles from "./joinScandicFriendsCard.module.css"
|
|||||||
type Props = {
|
type Props = {
|
||||||
name?: string
|
name?: string
|
||||||
}
|
}
|
||||||
export default function JoinScandicFriendsCard({ name = "join" }: Props) {
|
export function JoinScandicFriendsCard({ name = "join" }: Props) {
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const loginPathname = useLazyPathname({ includeSearchParams: true })
|
const loginPathname = useLazyPathname({ includeSearchParams: true })
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
"use client"
|
||||||
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
|
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
|
||||||
|
import { membershipTermsAndConditions } from "@scandic-hotels/common/constants/routes/membershipTermsAndConditions"
|
||||||
|
import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting"
|
||||||
|
import { Button } from "@scandic-hotels/design-system/Button"
|
||||||
|
import Footnote from "@scandic-hotels/design-system/Footnote"
|
||||||
|
import Checkbox from "@scandic-hotels/design-system/Form/Checkbox"
|
||||||
|
import Link from "@scandic-hotels/design-system/Link"
|
||||||
|
import { toast } from "@scandic-hotels/design-system/Toast"
|
||||||
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
import { trpc } from "@scandic-hotels/trpc/client"
|
||||||
|
|
||||||
|
import { useRoomContext } from "../../../../../contexts/EnterDetails/RoomContext"
|
||||||
|
import useLang from "../../../../../hooks/useLang"
|
||||||
|
|
||||||
|
import styles from "./partnerSASJoinScandicFriendsCard.module.css"
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
name?: string
|
||||||
|
}
|
||||||
|
export function PartnerSASJoinScandicFriendsCard({ name = "join" }: Props) {
|
||||||
|
const lang = useLang()
|
||||||
|
const intl = useIntl()
|
||||||
|
const { data: euroBonusProfile } =
|
||||||
|
trpc.partner.sas.getEuroBonusProfile.useQuery()
|
||||||
|
|
||||||
|
const {
|
||||||
|
room,
|
||||||
|
actions: { updateJoin },
|
||||||
|
} = useRoomContext()
|
||||||
|
|
||||||
|
function onChange(event: { target: { value: boolean } }) {
|
||||||
|
updateJoin(event.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!euroBonusProfile || euroBonusProfile.linkStatus !== "UNLINKED") {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!("member" in room.roomRate) || !room.roomRate.member) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.cardContainer}>
|
||||||
|
<Typography variant="Title/Subtitle/md">
|
||||||
|
<h2 className={styles.priceContainer}>
|
||||||
|
<span>
|
||||||
|
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||||
|
<>
|
||||||
|
NOT IMPLEMENTED
|
||||||
|
<br />
|
||||||
|
{intl.formatMessage({
|
||||||
|
defaultMessage: "Get the Scandic Friends room price",
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||||
|
{`: `}
|
||||||
|
</span>
|
||||||
|
<span className={styles.price}>
|
||||||
|
{formatPrice(
|
||||||
|
intl,
|
||||||
|
room.roomRate.member.localPrice.pricePerStay ?? 0,
|
||||||
|
room.roomRate.member.localPrice.currency ?? CurrencyEnum.Unknown
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</h2>
|
||||||
|
</Typography>
|
||||||
|
<Checkbox
|
||||||
|
name={name}
|
||||||
|
className={styles.checkBox}
|
||||||
|
registerOptions={{ onChange }}
|
||||||
|
>
|
||||||
|
<Typography variant="Body/Paragraph/mdRegular">
|
||||||
|
<div>
|
||||||
|
{intl.formatMessage({
|
||||||
|
defaultMessage: "Join Scandic Friends now",
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</Typography>
|
||||||
|
</Checkbox>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant={"Tertiary"}
|
||||||
|
size={"Small"}
|
||||||
|
typography={"Body/Paragraph/mdBold"}
|
||||||
|
color="Inverted"
|
||||||
|
className={styles.login}
|
||||||
|
onClick={() => toast.error("TODO: Not implemented")}
|
||||||
|
>
|
||||||
|
{intl.formatMessage({
|
||||||
|
defaultMessage: "Link",
|
||||||
|
})}
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<div className={styles.terms}>
|
||||||
|
<Footnote color="uiTextPlaceholder">
|
||||||
|
{intl.formatMessage(
|
||||||
|
{
|
||||||
|
defaultMessage:
|
||||||
|
"By joining you accept the <termsAndConditionsLink>Terms and Conditions</termsAndConditionsLink>. The Scandic Friends Membership is valid until further notice, but can at any time be terminated by contacting Scandic Customer Service.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
termsAndConditionsLink: (str) => (
|
||||||
|
<Link
|
||||||
|
textDecoration="underline"
|
||||||
|
size="tiny"
|
||||||
|
target="_blank"
|
||||||
|
href={membershipTermsAndConditions[lang]}
|
||||||
|
>
|
||||||
|
{str}
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</Footnote>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
.cardContainer {
|
||||||
|
align-self: flex-start;
|
||||||
|
background-color: orchid;
|
||||||
|
color: white;
|
||||||
|
border-radius: var(--Corner-radius-lg);
|
||||||
|
display: grid;
|
||||||
|
gap: var(--Space-x2);
|
||||||
|
padding: var(--Space-x2);
|
||||||
|
grid-template-areas:
|
||||||
|
"price login"
|
||||||
|
"checkbox checkbox"
|
||||||
|
"terms terms";
|
||||||
|
width: min(100%, 696px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.priceContainer {
|
||||||
|
grid-area: price;
|
||||||
|
margin-bottom: var(--Space-x1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.price {
|
||||||
|
color: var(--Text-Accent-Primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.login {
|
||||||
|
grid-area: login;
|
||||||
|
align-self: center;
|
||||||
|
justify-self: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkBox {
|
||||||
|
align-self: center;
|
||||||
|
grid-area: checkbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
.terms {
|
||||||
|
grid-area: terms;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 768px) {
|
||||||
|
.cardContainer {
|
||||||
|
grid-template-columns: 1fr auto auto;
|
||||||
|
grid-template-rows: auto auto;
|
||||||
|
gap: var(--Space-x3);
|
||||||
|
grid-template-areas:
|
||||||
|
"price checkbox login"
|
||||||
|
"terms terms terms";
|
||||||
|
}
|
||||||
|
|
||||||
|
.priceContainer {
|
||||||
|
margin-bottom: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import { useIntl } from "react-intl"
|
|||||||
import Caption from "@scandic-hotels/design-system/Caption"
|
import Caption from "@scandic-hotels/design-system/Caption"
|
||||||
import DateSelect from "@scandic-hotels/design-system/Form/Date"
|
import DateSelect from "@scandic-hotels/design-system/Form/Date"
|
||||||
|
|
||||||
|
import { useBookingFlowConfig } from "../../../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||||
import useLang from "../../../../../hooks/useLang"
|
import useLang from "../../../../../hooks/useLang"
|
||||||
import BookingFlowInput from "../../../../BookingFlowInput"
|
import BookingFlowInput from "../../../../BookingFlowInput"
|
||||||
import { getErrorMessage } from "../../../../BookingFlowInput/errors"
|
import { getErrorMessage } from "../../../../BookingFlowInput/errors"
|
||||||
@@ -28,6 +29,7 @@ export default function Signup({
|
|||||||
}) {
|
}) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
|
const config = useBookingFlowConfig()
|
||||||
|
|
||||||
const [isJoinChecked, setIsJoinChecked] = useState(false)
|
const [isJoinChecked, setIsJoinChecked] = useState(false)
|
||||||
|
|
||||||
@@ -65,6 +67,7 @@ export default function Signup({
|
|||||||
year: intl.formatMessage({ defaultMessage: "Year" }),
|
year: intl.formatMessage({ defaultMessage: "Year" }),
|
||||||
errorMessage: getErrorMessage(
|
errorMessage: getErrorMessage(
|
||||||
intl,
|
intl,
|
||||||
|
config.variant,
|
||||||
errors["dateOfBirth"]?.message?.toString()
|
errors["dateOfBirth"]?.message?.toString()
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import CountrySelect from "@scandic-hotels/design-system/Form/Country"
|
|||||||
import Phone from "@scandic-hotels/design-system/Form/Phone"
|
import Phone from "@scandic-hotels/design-system/Form/Phone"
|
||||||
import { useFormTracking } from "@scandic-hotels/tracking/useFormTracking"
|
import { useFormTracking } from "@scandic-hotels/tracking/useFormTracking"
|
||||||
|
|
||||||
|
import { useBookingFlowConfig } from "../../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||||
import { useRoomContext } from "../../../../contexts/EnterDetails/RoomContext"
|
import { useRoomContext } from "../../../../contexts/EnterDetails/RoomContext"
|
||||||
import useLang from "../../../../hooks/useLang"
|
import useLang from "../../../../hooks/useLang"
|
||||||
import { getFormattedCountryList } from "../../../../misc/getFormatedCountryList"
|
import { getFormattedCountryList } from "../../../../misc/getFormatedCountryList"
|
||||||
@@ -20,7 +21,8 @@ import BookingFlowInput from "../../../BookingFlowInput"
|
|||||||
import { getErrorMessage } from "../../../BookingFlowInput/errors"
|
import { getErrorMessage } from "../../../BookingFlowInput/errors"
|
||||||
import MemberPriceModal from "../MemberPriceModal"
|
import MemberPriceModal from "../MemberPriceModal"
|
||||||
import { SpecialRequests } from "../SpecialRequests"
|
import { SpecialRequests } from "../SpecialRequests"
|
||||||
import JoinScandicFriendsCard from "./JoinScandicFriendsCard"
|
import { JoinScandicFriendsCard } from "./JoinScandicFriendsCard"
|
||||||
|
import { PartnerSASJoinScandicFriendsCard } from "./PartnerSASJoinScandicFriendsCard"
|
||||||
import {
|
import {
|
||||||
type GuestDetailsSchema,
|
type GuestDetailsSchema,
|
||||||
guestDetailsSchema,
|
guestDetailsSchema,
|
||||||
@@ -40,6 +42,7 @@ const formID = "enter-details"
|
|||||||
export default function Details({ user }: DetailsProps) {
|
export default function Details({ user }: DetailsProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
|
const config = useBookingFlowConfig()
|
||||||
|
|
||||||
const { lastRoom, addPreSubmitCallback } = useEnterDetailsStore((state) => ({
|
const { lastRoom, addPreSubmitCallback } = useEnterDetailsStore((state) => ({
|
||||||
lastRoom: state.lastRoom,
|
lastRoom: state.lastRoom,
|
||||||
@@ -153,7 +156,15 @@ export default function Details({ user }: DetailsProps) {
|
|||||||
id={`${formID}-room-${roomNr}`}
|
id={`${formID}-room-${roomNr}`}
|
||||||
onSubmit={methods.handleSubmit(onSubmit)}
|
onSubmit={methods.handleSubmit(onSubmit)}
|
||||||
>
|
>
|
||||||
{user || !memberRate ? null : <JoinScandicFriendsCard />}
|
{config.variant === "scandic" && (
|
||||||
|
<>{!user || !memberRate ? null : <JoinScandicFriendsCard />}</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{config.variant === "partner-sas" && (
|
||||||
|
<>
|
||||||
|
{user || !memberRate ? null : <PartnerSASJoinScandicFriendsCard />}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<Footnote
|
<Footnote
|
||||||
color="uiTextHighContrast"
|
color="uiTextHighContrast"
|
||||||
@@ -194,6 +205,7 @@ export default function Details({ user }: DetailsProps) {
|
|||||||
countries={getFormattedCountryList(intl)}
|
countries={getFormattedCountryList(intl)}
|
||||||
errorMessage={getErrorMessage(
|
errorMessage={getErrorMessage(
|
||||||
intl,
|
intl,
|
||||||
|
config.variant,
|
||||||
formState.errors.countryCode?.message
|
formState.errors.countryCode?.message
|
||||||
)}
|
)}
|
||||||
name="countryCode"
|
name="countryCode"
|
||||||
@@ -219,6 +231,7 @@ export default function Details({ user }: DetailsProps) {
|
|||||||
defaultCountryCode={getDefaultCountryFromLang(lang)}
|
defaultCountryCode={getDefaultCountryFromLang(lang)}
|
||||||
errorMessage={getErrorMessage(
|
errorMessage={getErrorMessage(
|
||||||
intl,
|
intl,
|
||||||
|
config.variant,
|
||||||
formState.errors.phoneNumber?.message
|
formState.errors.phoneNumber?.message
|
||||||
)}
|
)}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
export enum ScandicPartnersEnum {
|
|
||||||
sas = "sas",
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user