import "@/app/globals.css"
import "@scandic-hotels/design-system/style.css"

import { overview } from "@/constants/routes/webviews"
import { serverClient } from "@/lib/trpc/server"

import MaxWidth from "@/components/MaxWidth"
import Content from "@/components/MyPages/AccountPage/Webview/Content"
import LinkToOverview from "@/components/Webviews/LinkToOverview"

import styles from "./accountPage.module.css"

import { LangParams } from "@/types/params"

export default async function MyPages({ lang }: LangParams) {
  const accountPage = await serverClient().contentstack.accountPage.get()
  if (!accountPage) {
    return null
  }

  const linkToOverview = `/${lang}/webview${accountPage.url}` !== overview[lang]

  return (
    <MaxWidth className={styles.blocks} tag="main">
      {linkToOverview ? <LinkToOverview lang={lang} /> : null}
      <Content lang={lang} content={accountPage.content} />
    </MaxWidth>
  )
}
