import { getSession } from '@/lib/session'
import { getRealmName, realmSlug } from '@/lib/realm'
import { SiteHeader } from './SiteHeader'

export async function Header() {
  const session = await getSession()
  const loggedIn = Boolean(session.username)
  // Django muestra bnet_email si existe, si no el username.
  const accountLabel = session.bnetEmail || session.username || ''
  // Nombre y enlaces del reino según realmlist (p. ej. Trinity → /trinity-realm, /trinity-players).
  const realmName = await getRealmName()
  const slug = realmSlug(realmName)
  const realmHref = `/${slug}-realm`
  const playersHref = `/${slug}-players`

  return (
    <SiteHeader
      loggedIn={loggedIn}
      accountLabel={accountLabel}
      realmName={realmName}
      realmHref={realmHref}
      playersHref={playersHref}
    />
  )
}
