import { Suspense } from "react"

import { env } from "@/env/server"

import SitewideAlert, { preload } from "@/components/SitewideAlert"
import { setLang } from "@/i18n/serverContext"

import type { LangParams, PageArgs } from "@/types/params"

export default function SitewideAlertPage({ params }: PageArgs<LangParams>) {
  if (!env.SHOW_SITE_WIDE_ALERT) {
    return null
  }

  setLang(params.lang)
  void preload()

  return (
    <Suspense>
      <SitewideAlert />
    </Suspense>
  )
}
