function MobileSidebar({ active = 'bank', onSelect, planId, branchLimit, branchUser, isOpen, onClose }) {
const MobileNavItem = ({ id, label, icon = '📋', locked = false, activeId, onClick, description }) => (
{
e.preventDefault();
if (locked) return;
onClick?.(id);
onClose?.(); // Close sidebar after navigation
try { location.hash = '#' + id; } catch {}
}}
>
{icon}
{locked && 🔒}
{label}
{description && {description}}
›
);
const canUseBranch = planId === 'sales-gold' || planId === 'sales-premium';
const isBranch = !!branchUser;
// Handle backdrop click
const handleBackdropClick = (e) => {
if (e.target === e.currentTarget) {
onClose?.();
}
};
// Handle escape key
React.useEffect(() => {
const handleEscape = (e) => {
if (e.key === 'Escape' && isOpen) {
onClose?.();
}
};
if (isOpen) {
document.addEventListener('keydown', handleEscape);
document.body.style.overflow = 'hidden'; // Prevent background scroll
} else {
document.body.style.overflow = '';
}
return () => {
document.removeEventListener('keydown', handleEscape);
document.body.style.overflow = '';
};
}, [isOpen, onClose]);
return (
<>
{/* Backdrop */}
{/* Sidebar */}
>
);
}
// Register globally for the in-browser JSX loader
window.MobileSidebar = MobileSidebar;