import { useLocation } from 'react-router-dom'
import { useDashboardDocumentTitle, useLocale } from '@meshkee/dashboard-ui'
import { useTenantBranding } from '../context/TenantBrandingContext'
import { getBusinessRouteTitleRules, translate } from '../i18n/messages'

export function DashboardDocumentTitle() {
  const { pathname } = useLocation()
  const { businessName } = useTenantBranding()
  const { locale } = useLocale()

  useDashboardDocumentTitle({
    businessName,
    dashboardName: translate(locale, 'app.dashboardName'),
    pathname,
    routeRules: getBusinessRouteTitleRules(locale),
  })

  return null
}
