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:
@@ -12,6 +12,7 @@ import CountrySelect from "@scandic-hotels/design-system/Form/Country"
|
||||
import Phone from "@scandic-hotels/design-system/Form/Phone"
|
||||
import { useFormTracking } from "@scandic-hotels/tracking/useFormTracking"
|
||||
|
||||
import { useBookingFlowConfig } from "../../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||
import { useRoomContext } from "../../../../contexts/EnterDetails/RoomContext"
|
||||
import useLang from "../../../../hooks/useLang"
|
||||
import { getFormattedCountryList } from "../../../../misc/getFormatedCountryList"
|
||||
@@ -29,6 +30,7 @@ const formID = "enter-details"
|
||||
export default function Details() {
|
||||
const intl = useIntl()
|
||||
const lang = useLang()
|
||||
const config = useBookingFlowConfig()
|
||||
|
||||
const { addPreSubmitCallback, rooms } = useEnterDetailsStore((state) => ({
|
||||
addPreSubmitCallback: state.actions.addPreSubmitCallback,
|
||||
@@ -205,7 +207,11 @@ export default function Details() {
|
||||
<CountrySelect
|
||||
className={styles.fullWidth}
|
||||
countries={getFormattedCountryList(intl)}
|
||||
errorMessage={getErrorMessage(intl, errors.countryCode?.message)}
|
||||
errorMessage={getErrorMessage(
|
||||
intl,
|
||||
config.variant,
|
||||
errors.countryCode?.message
|
||||
)}
|
||||
label={intl.formatMessage({
|
||||
defaultMessage: "Country",
|
||||
})}
|
||||
@@ -227,7 +233,11 @@ export default function Details() {
|
||||
})}
|
||||
countriesWithTranslatedName={getFormattedCountryList(intl)}
|
||||
defaultCountryCode={getDefaultCountryFromLang(lang)}
|
||||
errorMessage={getErrorMessage(intl, errors.phoneNumber?.message)}
|
||||
errorMessage={getErrorMessage(
|
||||
intl,
|
||||
config.variant,
|
||||
errors.phoneNumber?.message
|
||||
)}
|
||||
className={styles.fullWidth}
|
||||
label={intl.formatMessage({
|
||||
defaultMessage: "Phone number",
|
||||
|
||||
@@ -21,7 +21,7 @@ import styles from "./joinScandicFriendsCard.module.css"
|
||||
type Props = {
|
||||
name?: string
|
||||
}
|
||||
export default function JoinScandicFriendsCard({ name = "join" }: Props) {
|
||||
export function JoinScandicFriendsCard({ name = "join" }: Props) {
|
||||
const lang = useLang()
|
||||
const intl = useIntl()
|
||||
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 DateSelect from "@scandic-hotels/design-system/Form/Date"
|
||||
|
||||
import { useBookingFlowConfig } from "../../../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||
import useLang from "../../../../../hooks/useLang"
|
||||
import BookingFlowInput from "../../../../BookingFlowInput"
|
||||
import { getErrorMessage } from "../../../../BookingFlowInput/errors"
|
||||
@@ -28,6 +29,7 @@ export default function Signup({
|
||||
}) {
|
||||
const intl = useIntl()
|
||||
const lang = useLang()
|
||||
const config = useBookingFlowConfig()
|
||||
|
||||
const [isJoinChecked, setIsJoinChecked] = useState(false)
|
||||
|
||||
@@ -65,6 +67,7 @@ export default function Signup({
|
||||
year: intl.formatMessage({ defaultMessage: "Year" }),
|
||||
errorMessage: getErrorMessage(
|
||||
intl,
|
||||
config.variant,
|
||||
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 { useFormTracking } from "@scandic-hotels/tracking/useFormTracking"
|
||||
|
||||
import { useBookingFlowConfig } from "../../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||
import { useRoomContext } from "../../../../contexts/EnterDetails/RoomContext"
|
||||
import useLang from "../../../../hooks/useLang"
|
||||
import { getFormattedCountryList } from "../../../../misc/getFormatedCountryList"
|
||||
@@ -20,7 +21,8 @@ import BookingFlowInput from "../../../BookingFlowInput"
|
||||
import { getErrorMessage } from "../../../BookingFlowInput/errors"
|
||||
import MemberPriceModal from "../MemberPriceModal"
|
||||
import { SpecialRequests } from "../SpecialRequests"
|
||||
import JoinScandicFriendsCard from "./JoinScandicFriendsCard"
|
||||
import { JoinScandicFriendsCard } from "./JoinScandicFriendsCard"
|
||||
import { PartnerSASJoinScandicFriendsCard } from "./PartnerSASJoinScandicFriendsCard"
|
||||
import {
|
||||
type GuestDetailsSchema,
|
||||
guestDetailsSchema,
|
||||
@@ -40,6 +42,7 @@ const formID = "enter-details"
|
||||
export default function Details({ user }: DetailsProps) {
|
||||
const intl = useIntl()
|
||||
const lang = useLang()
|
||||
const config = useBookingFlowConfig()
|
||||
|
||||
const { lastRoom, addPreSubmitCallback } = useEnterDetailsStore((state) => ({
|
||||
lastRoom: state.lastRoom,
|
||||
@@ -153,7 +156,15 @@ export default function Details({ user }: DetailsProps) {
|
||||
id={`${formID}-room-${roomNr}`}
|
||||
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}>
|
||||
<Footnote
|
||||
color="uiTextHighContrast"
|
||||
@@ -194,6 +205,7 @@ export default function Details({ user }: DetailsProps) {
|
||||
countries={getFormattedCountryList(intl)}
|
||||
errorMessage={getErrorMessage(
|
||||
intl,
|
||||
config.variant,
|
||||
formState.errors.countryCode?.message
|
||||
)}
|
||||
name="countryCode"
|
||||
@@ -219,6 +231,7 @@ export default function Details({ user }: DetailsProps) {
|
||||
defaultCountryCode={getDefaultCountryFromLang(lang)}
|
||||
errorMessage={getErrorMessage(
|
||||
intl,
|
||||
config.variant,
|
||||
formState.errors.phoneNumber?.message
|
||||
)}
|
||||
label={intl.formatMessage({
|
||||
|
||||
Reference in New Issue
Block a user