"use client" import { useFormContext, useWatch } from "react-hook-form" import { useIntl } from "react-intl" import { MaterialIcon } from "@scandic-hotels/design-system/Icons" import { dt } from "@/lib/dt" 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 Voucher, { VoucherSkeleton } from "./Voucher" import styles from "./formContent.module.css" import type { BookingWidgetSchema } from "@/types/components/bookingWidget" import type { BookingWidgetFormContentProps } from "@/types/components/form/bookingwidget" export default function FormContent({ locations, formId, onSubmit, isSearching, }: BookingWidgetFormContentProps) { const intl = useIntl() const { formState: { errors }, } = useFormContext() const bookingCodeError = errors["bookingCode"]?.value const selectedDate = useWatch({ name: "date" }) const roomsLabel = intl.formatMessage({ id: "Rooms & Guests" }) const nights = dt(selectedDate.toDate).diff(dt(selectedDate.fromDate), "days") return ( <>
{nights > 0 ? intl.formatMessage( { id: "{totalNights, plural, one {# night} other {# nights}}", }, { totalNights: nights } ) : intl.formatMessage({ id: "Check in", })}
{bookingCodeError?.message?.indexOf("Multi-room") === 0 ? ( ) : null}
) } export function BookingWidgetFormContentSkeleton() { const intl = useIntl() return (
{intl.formatMessage( { id: "{totalNights, plural, one {# night} other {# nights}}" }, { totalNights: 0 } )}
{intl.formatMessage({ id: "Rooms & Guests" })}
) }