"use client" import { usePathname } from "next/navigation" import { useFormContext, useWatch } from "react-hook-form" import { useIntl } from "react-intl" import { dt } from "@scandic-hotels/common/dt" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking" import { hotelreservation } from "@/constants/routes/hotelReservation" import DatePicker from "@/components/DatePicker" import GuestsRoomsPickerForm from "@/components/GuestsRoomsPicker" import SkeletonShimmer from "@/components/SkeletonShimmer" import Button from "@/components/TempDesignSystem/Button" import useLang from "@/hooks/useLang" import { RemoveExtraRooms } from "./BookingCode" import { Search, SearchSkeleton } from "./Search" import { isMultiRoomError } from "./utils" import ValidationError from "./ValidationError" 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({ formId, onSubmit, isSearching, }: BookingWidgetFormContentProps) { const intl = useIntl() const { formState: { errors, isDirty }, } = useFormContext() const lang = useLang() const pathName = usePathname() const isBookingFlow = pathName.includes(hotelreservation(lang)) const selectedDate = useWatch({ name: "date" }) const nights = dt(selectedDate.toDate).diff(dt(selectedDate.fromDate), "days") return (
{errors.search && }
{isMultiRoomError(errors.bookingCode?.value?.message) || isMultiRoomError(errors[REDEMPTION]?.message) ? (
) : null}
) } export function BookingWidgetFormContentSkeleton() { const intl = useIntl() return (
) }