Migrate to a monorepo setup - step 1 * Move web to subfolder /apps/scandic-web * Yarn + transitive deps - Move to yarn - design-system package removed for now since yarn doesn't support the parameter for token (ie project currently broken) - Add missing transitive dependencies as Yarn otherwise prevents these imports - VS Code doesn't pick up TS path aliases unless you open /apps/scandic-web instead of root (will be fixed with monorepo) * Pin framer-motion to temporarily fix typing issue https://github.com/adobe/react-spectrum/issues/7494 * Pin zod to avoid typ error There seems to have been a breaking change in the types returned by zod where error is now returned as undefined instead of missing in the type. We should just handle this but to avoid merge conflicts just pin the dependency for now. * Pin react-intl version Pin version of react-intl to avoid tiny type issue where formatMessage does not accept a generic any more. This will be fixed in a future commit, but to avoid merge conflicts just pin for now. * Pin typescript version Temporarily pin version as newer versions as stricter and results in a type error. Will be fixed in future commit after merge. * Setup workspaces * Add design-system as a monorepo package * Remove unused env var DESIGN_SYSTEM_ACCESS_TOKEN * Fix husky for monorepo setup * Update netlify.toml * Add lint script to root package.json * Add stub readme * Fix react-intl formatMessage types * Test netlify.toml in root * Remove root toml * Update netlify.toml publish path * Remove package-lock.json * Update build for branch/preview builds Approved-by: Linus Flood
121 lines
4.0 KiB
TypeScript
121 lines
4.0 KiB
TypeScript
import { useFormContext } from "react-hook-form"
|
|
import { useIntl } from "react-intl"
|
|
|
|
import {
|
|
bookingTermsAndConditions,
|
|
privacyPolicy,
|
|
} from "@/constants/currentWebHrefs"
|
|
import { useAddAncillaryStore } from "@/stores/my-stay/add-ancillary-flow"
|
|
|
|
import { CreditCard } from "@/components/Icons"
|
|
import Divider from "@/components/TempDesignSystem/Divider"
|
|
import Checkbox from "@/components/TempDesignSystem/Form/Checkbox"
|
|
import Link from "@/components/TempDesignSystem/Link"
|
|
import Body from "@/components/TempDesignSystem/Text/Body"
|
|
import Caption from "@/components/TempDesignSystem/Text/Caption"
|
|
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
|
import useLang from "@/hooks/useLang"
|
|
import { formatPrice } from "@/utils/numberFormatting"
|
|
|
|
import styles from "./confirmationStep.module.css"
|
|
|
|
export default function ConfirmationStep() {
|
|
const { watch } = useFormContext()
|
|
const { selectedAncillary } = useAddAncillaryStore()
|
|
const intl = useIntl()
|
|
const lang = useLang()
|
|
|
|
const quantityWithPoints = watch("quantityWithPoints")
|
|
const quantityWithCard = watch("quantityWithCard")
|
|
|
|
if (!selectedAncillary) {
|
|
return null
|
|
}
|
|
|
|
const totalPrice = quantityWithCard
|
|
? selectedAncillary.price.total * quantityWithCard
|
|
: null
|
|
|
|
const totalPoints =
|
|
quantityWithPoints && selectedAncillary.points
|
|
? selectedAncillary.points * quantityWithPoints
|
|
: null
|
|
|
|
return (
|
|
<div className={styles.modalContent}>
|
|
<header>
|
|
<Subtitle type="two">
|
|
{intl.formatMessage({
|
|
id: "Reserve with Card",
|
|
})}
|
|
</Subtitle>
|
|
</header>
|
|
<Body>
|
|
{intl.formatMessage({
|
|
id: "Payment will be made on check-in. The card will be only used to guarantee the ancillary in case of no-show.",
|
|
})}
|
|
</Body>
|
|
<div className={styles.card}>
|
|
<CreditCard color="black" />
|
|
<Body textTransform="bold">{"MasterCard"}</Body>
|
|
<Body color="uiTextMediumContrast">{"**** 1234"}</Body>
|
|
</div>
|
|
<Checkbox name="termsAndConditions" registerOptions={{ required: true }}>
|
|
<Caption>
|
|
{intl.formatMessage(
|
|
{
|
|
id: "Yes, I accept the general <termsAndConditionsLink>Terms & Conditions</termsAndConditionsLink>, and understand that Scandic will process my personal data in accordance with <privacyPolicyLink>Scandic's Privacy policy</privacyPolicyLink>. There you can learn more about what data we process, your rights and where to turn if you have questions.",
|
|
},
|
|
{
|
|
termsAndConditionsLink: (str) => (
|
|
<Link
|
|
className={styles.link}
|
|
variant="underscored"
|
|
href={bookingTermsAndConditions[lang]}
|
|
target="_blank"
|
|
>
|
|
{str}
|
|
</Link>
|
|
),
|
|
privacyPolicyLink: (str) => (
|
|
<Link
|
|
className={styles.link}
|
|
variant="underscored"
|
|
href={privacyPolicy[lang]}
|
|
target="_blank"
|
|
>
|
|
{str}
|
|
</Link>
|
|
),
|
|
}
|
|
)}
|
|
</Caption>
|
|
</Checkbox>
|
|
|
|
<div className={styles.price}>
|
|
<Caption>
|
|
{intl.formatMessage(
|
|
{ id: "<b>Total price</b> (incl VAT)" },
|
|
{ b: (str) => <b>{str}</b> }
|
|
)}
|
|
</Caption>
|
|
{totalPrice !== null && (
|
|
<Body textTransform="bold" color="uiTextHighContrast">
|
|
{formatPrice(intl, totalPrice, selectedAncillary.price.currency)}
|
|
</Body>
|
|
)}
|
|
{totalPoints !== null && (
|
|
<div>
|
|
<div>
|
|
<Divider variant="vertical" color="subtle" />
|
|
</div>
|
|
<Body textTransform="bold" color="uiTextHighContrast">
|
|
{totalPoints} {intl.formatMessage({ id: "points" })}
|
|
</Body>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|