import { useState, memo, useCallback, useMemo } from "react"; import { ArrowRight, Headset } from "lucide-react"; import CallDialog from "./CallDialog"; interface HeaderWithSupportProps { title: string; onBack: () => void; hideSupportButton?: boolean; } const HeaderWithSupport = memo(function HeaderWithSupport({ title, onBack, hideSupportButton, }: HeaderWithSupportProps) { const [isCallModalOpen, setIsCallModalOpen] = useState(false); const supportPhone = useMemo( () => import.meta.env.VITE_SUPPORT_PHONE || "", [] ); const handleSupportClick = useCallback(() => { setIsCallModalOpen(true); }, []); const handleCallConfirm = useCallback(() => { window.location.href = `tel:${supportPhone}`; setIsCallModalOpen(false); }, [supportPhone]); const handleKeyDown = useCallback( (e: React.KeyboardEvent) => { if (e.key === "Enter") { handleSupportClick(); } }, [handleSupportClick] ); return ( <> {/* Mobile only — on desktop the dashboard sidebar / desktop header stands in for this back+support bar. */}
{title}
{!hideSupportButton && (