"use client" import { type PropsWithChildren, useEffect, useRef } from "react" import { useIntl } from "react-intl" import { useEnterDetailsStore } from "@/stores/enter-details" import { formId } from "@/components/HotelReservation/EnterDetails/Payment/PaymentClient" import Button from "@/components/TempDesignSystem/Button" import Caption from "@/components/TempDesignSystem/Text/Caption" import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import styles from "./bottomSheet.module.css" export default function SummaryBottomSheet({ children }: PropsWithChildren) { const intl = useIntl() const scrollY = useRef(0) const { isSummaryOpen, toggleSummaryOpen, totalPrice, isSubmittingDisabled } = useEnterDetailsStore((state) => ({ isSummaryOpen: state.isSummaryOpen, toggleSummaryOpen: state.actions.toggleSummaryOpen, totalPrice: state.totalPrice, isSubmittingDisabled: state.isSubmittingDisabled, })) useEffect(() => { if (isSummaryOpen) { scrollY.current = window.scrollY document.body.style.position = "fixed" document.body.style.top = `-${scrollY.current}px` } else { document.body.style.position = "" document.body.style.top = "" window.scrollTo({ top: scrollY.current, left: 0, behavior: "instant", }) } return () => { document.body.style.position = "" document.body.style.top = "" } }, [isSummaryOpen]) return (
{children}
) }