import { useEffect, useState, type MouseEvent } from 'react' import { isWithinBusinessHours } from '../../shared/business-hours' import { contacts } from '../data/content' import { cx } from '../lib/cx' import { reportCallClick } from '../lib/lead' import { ButtonLink, buttonClass } from './Button' import { PhoneIcon } from './Icons' /** * The primary CTA's home below 760px, where the header cannot hold it without * crushing the logo. See `SiteHeader`. * * It waits for the hero — whose own two buttons say the same thing — to scroll * away, and steps back down while the form is on screen, so it never sits on * top of the fields it points at. That also keeps it clear of the submit * button, which is the one control it could plausibly be mistaken for. */ export function MobileActionBar({ onAfterHoursCall }: { onAfterHoursCall: () => void }) { const [shown, setShown] = useState(false) // Nobody answers out of hours, so the number opens the callback form instead // of the dialler — and is not reported as a call, since none happens. const onPhoneClick = (event: MouseEvent) => { if (isWithinBusinessHours()) { reportCallClick() return } event.preventDefault() onAfterHoursCall() } useEffect(() => { const hero = document.getElementById('top') const form = document.getElementById('proposal') if (!hero || !form) return let heroOnScreen = true let formOnScreen = false const observer = new IntersectionObserver((entries) => { for (const entry of entries) { if (entry.target === hero) heroOnScreen = entry.isIntersecting if (entry.target === form) formOnScreen = entry.isIntersecting } setShown(!heroOnScreen && !formOnScreen) }) observer.observe(hero) observer.observe(form) return () => observer.disconnect() }, []) return (
Получить предложение
) }