import React from 'react'; import { NavLink } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { cn } from '@/lib/utils'; import toast from 'react-hot-toast'; import { ADMIN_HOME_PATH, ADMIN_EVENTS_PATH, ADMIN_SETTINGS_PATH, ADMIN_BILLING_PATH, ADMIN_ENGAGEMENT_PATH, } from '../constants'; import { LanguageSwitcher } from './LanguageSwitcher'; import { registerApiErrorListener } from '../lib/apiError'; const navItems = [ { to: ADMIN_HOME_PATH, labelKey: 'navigation.dashboard', end: true }, { to: ADMIN_EVENTS_PATH, labelKey: 'navigation.events' }, { to: ADMIN_ENGAGEMENT_PATH, labelKey: 'navigation.engagement' }, { to: ADMIN_BILLING_PATH, labelKey: 'navigation.billing' }, { to: ADMIN_SETTINGS_PATH, labelKey: 'navigation.settings' }, ]; interface AdminLayoutProps { title: string; subtitle?: string; actions?: React.ReactNode; children: React.ReactNode; } export function AdminLayout({ title, subtitle, actions, children }: AdminLayoutProps) { const { t } = useTranslation('common'); React.useEffect(() => { document.body.classList.add('tenant-admin-theme'); return () => { document.body.classList.remove('tenant-admin-theme'); }; }, []); React.useEffect(() => { const unsubscribe = registerApiErrorListener((detail) => { const fallback = t('errors.generic'); const message = detail?.message?.trim() ? detail.message : fallback; toast.error(message, { id: detail?.code ? `api-error-${detail.code}` : undefined, }); }); return unsubscribe; }, [t]); return (

{t('app.brand')}

{title}

{subtitle &&

{subtitle}

}
{actions}
{children}
); }