diff --git a/apps/scandic-web/components/DatePicker/Range/Desktop.tsx b/apps/scandic-web/components/DatePicker/Range/Desktop.tsx index ff1b235c8..2c5161d53 100644 --- a/apps/scandic-web/components/DatePicker/Range/Desktop.tsx +++ b/apps/scandic-web/components/DatePicker/Range/Desktop.tsx @@ -29,7 +29,7 @@ export default function DatePickerRangeDesktop({ }: DatePickerRangeProps) { const lang = useLang() const intl = useIntl() - const [month, setMonth] = useState(new Date()) + const [month, setMonth] = useState(selectedRange?.from ?? new Date()) /** English is default language and doesn't need to be imported */ const locale = lang === Lang.en ? undefined : locales[lang] diff --git a/apps/scandic-web/components/DatePicker/Range/Mobile.tsx b/apps/scandic-web/components/DatePicker/Range/Mobile.tsx index 0079b095d..95712d841 100644 --- a/apps/scandic-web/components/DatePicker/Range/Mobile.tsx +++ b/apps/scandic-web/components/DatePicker/Range/Mobile.tsx @@ -74,6 +74,7 @@ export default function DatePickerRangeMobile({ lang={lang} locale={locale} mode="range" + defaultMonth={selectedRange?.from} /** Showing full year or what's left of it */ numberOfMonths={13} onSelect={handleOnSelect} diff --git a/apps/scandic-web/components/Forms/BookingWidget/FormContent/Search/index.tsx b/apps/scandic-web/components/Forms/BookingWidget/FormContent/Search/index.tsx index 945ca5a11..188c96719 100644 --- a/apps/scandic-web/components/Forms/BookingWidget/FormContent/Search/index.tsx +++ b/apps/scandic-web/components/Forms/BookingWidget/FormContent/Search/index.tsx @@ -225,7 +225,7 @@ export function SearchSkeleton() { const intl = useIntl() return (
-
+
{intl.formatMessage({ defaultMessage: "Where to?" })} diff --git a/apps/scandic-web/components/Forms/BookingWidget/FormContent/ValidationError/index.tsx b/apps/scandic-web/components/Forms/BookingWidget/FormContent/ValidationError/index.tsx new file mode 100644 index 000000000..586b38059 --- /dev/null +++ b/apps/scandic-web/components/Forms/BookingWidget/FormContent/ValidationError/index.tsx @@ -0,0 +1,32 @@ +import { useIntl } from "react-intl" + +import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" + +import Caption from "@/components/TempDesignSystem/Text/Caption" + +import styles from "./validationError.module.css" + +export default function ValidationError() { + const intl = useIntl() + + return ( +
+ + + {intl.formatMessage({ + defaultMessage: "Enter destination or hotel", + })} + + + {intl.formatMessage({ + defaultMessage: + "A destination or hotel name is needed to be able to search for a hotel room.", + })} + +
+ ) +} diff --git a/apps/scandic-web/components/Forms/BookingWidget/FormContent/ValidationError/validationError.module.css b/apps/scandic-web/components/Forms/BookingWidget/FormContent/ValidationError/validationError.module.css new file mode 100644 index 000000000..061fb6049 --- /dev/null +++ b/apps/scandic-web/components/Forms/BookingWidget/FormContent/ValidationError/validationError.module.css @@ -0,0 +1,36 @@ +.container { + position: absolute; + top: calc(100% + var(--Space-x2)); + background: var(--Surface-Primary-Default); + border-radius: var(--Corner-radius-lg); + box-shadow: 0px 0px 14px 6px rgba(0, 0, 0, 0.1); + padding: var(--Space-x15); + max-width: min(100vw, calc(360px - var(--Space-x2))); + width: 360px; + + display: flex; + flex-direction: column; + padding: var(--Space-x15); + align-items: flex-start; + gap: var(--Space-x05); + z-index: var(--dialog-z-index); +} + +.title { + display: flex; + align-items: center; + gap: var(--Space-x1); +} + +.message { + text-wrap: auto; +} + +@media screen and (min-width: 1367px) { + .container { + top: calc(100% + var(--Space-x1) + var(--Space-x2)); + left: calc(var(--Space-x1) * -1); + padding: var(--Space-x2); + max-width: 360px; + } +} diff --git a/apps/scandic-web/components/Forms/BookingWidget/FormContent/formContent.module.css b/apps/scandic-web/components/Forms/BookingWidget/FormContent/formContent.module.css index 3f33084ef..f097a2599 100644 --- a/apps/scandic-web/components/Forms/BookingWidget/FormContent/formContent.module.css +++ b/apps/scandic-web/components/Forms/BookingWidget/FormContent/formContent.module.css @@ -11,6 +11,7 @@ display: none; } +.where, .rooms, .when { position: relative; @@ -25,6 +26,10 @@ display: none; } +.label { + color: var(--Text-Accent-Primary); +} + @media screen and (max-width: 767px) { .voucherContainer { padding: var(--Spacing-x2) 0 var(--Spacing-x4); diff --git a/apps/scandic-web/components/Forms/BookingWidget/FormContent/index.tsx b/apps/scandic-web/components/Forms/BookingWidget/FormContent/index.tsx index f9578cce6..1fad7ffbe 100644 --- a/apps/scandic-web/components/Forms/BookingWidget/FormContent/index.tsx +++ b/apps/scandic-web/components/Forms/BookingWidget/FormContent/index.tsx @@ -4,6 +4,7 @@ import { useFormContext, useWatch } from "react-hook-form" import { useIntl } from "react-intl" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" +import { Typography } from "@scandic-hotels/design-system/Typography" import { dt } from "@/lib/dt" @@ -11,10 +12,10 @@ import DatePicker from "@/components/DatePicker" import GuestsRoomsPickerForm from "@/components/GuestsRoomsPicker" import SkeletonShimmer from "@/components/SkeletonShimmer" import Button from "@/components/TempDesignSystem/Button" -import Caption from "@/components/TempDesignSystem/Text/Caption" import { RemoveExtraRooms } from "./BookingCode" import { Search, SearchSkeleton } from "./Search" +import ValidationError from "./ValidationError" import Voucher, { VoucherSkeleton } from "./Voucher" import styles from "./formContent.module.css" @@ -37,19 +38,23 @@ export default function FormContent({ const nights = dt(selectedDate.toDate).diff(dt(selectedDate.fromDate), "days") return ( - <> -
-
-
- -
-
- +
+
+
+ + {errors.search && } +
+
+ +
-
- - -
+ +
-
- -
-
- -
-
- {errors.bookingCode?.value?.message?.indexOf("Multi-room") === 0 ? ( - - ) : null} - + + +
- +
+ +
+
+ +
+
+ {errors.bookingCode?.value?.message?.indexOf("Multi-room") === 0 ? ( + + ) : null} + +
+
) } @@ -141,25 +145,33 @@ export function BookingWidgetFormContentSkeleton() {
- - {intl.formatMessage( - { - defaultMessage: - "{totalNights, plural, one {# night} other {# nights}}", - }, - { totalNights: 0 } - )} - + + +
- - + + - + +
@@ -174,18 +186,17 @@ export function BookingWidgetFormContentSkeleton() { type="submit" disabled > - {intl.formatMessage({ defaultMessage: "Search", })} - + + diff --git a/apps/scandic-web/components/GuestsRoomsPicker/index.tsx b/apps/scandic-web/components/GuestsRoomsPicker/index.tsx index bd9109924..ca318c208 100644 --- a/apps/scandic-web/components/GuestsRoomsPicker/index.tsx +++ b/apps/scandic-web/components/GuestsRoomsPicker/index.tsx @@ -21,7 +21,11 @@ import styles from "./guests-rooms-picker.module.css" import type { BookingWidgetSchema } from "@/types/components/bookingWidget" import type { GuestsRoom } from "@/types/components/bookingWidget/guestsRoomsPicker" -export default function GuestsRoomsPickerForm() { +export default function GuestsRoomsPickerForm({ + ariaLabelledBy, +}: { + ariaLabelledBy?: string +}) { const { trigger } = useFormContext() const rooms = useWatch({ name: "rooms" }) @@ -115,6 +119,7 @@ export default function GuestsRoomsPickerForm() { triggerFn={() => { setIsOpen(true) }} + ariaLabelledBy={ariaLabelledBy} /> @@ -129,10 +134,12 @@ function Trigger({ rooms, className, triggerFn, + ariaLabelledBy, }: { rooms: GuestsRoom[] className: string triggerFn?: () => void + ariaLabelledBy?: string }) { const intl = useIntl() @@ -173,6 +180,7 @@ function Trigger({ className={`${className} ${styles.btn}`} type="button" onPress={triggerFn} + aria-labelledby={ariaLabelledBy} > {parts.join(", ")}