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 "./page.module.css"

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

export default async function MyPages({ params }: PageArgs<LangParams>) {
  const accountPage = await serverClient().contentstack.accountPage.get()

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

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