import { TrackingSDK } from "@scandic-hotels/tracking/TrackingSDK"

import { serverClient } from "@/lib/trpc/server"

import MaxWidth from "@/components/MaxWidth"
import Surprises from "@/components/MyPages/Surprises"
import Blocks from "@/components/Webviews/AccountPage/Blocks"

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

export default async function AccountPage() {
  const caller = await serverClient()
  const accountPageRes = await caller.contentstack.accountPage.get()

  if (!accountPageRes) {
    return null
  }

  const { tracking, accountPage } = accountPageRes

  return (
    <>
      <MaxWidth className={styles.blocks} tag="main">
        <Blocks content={accountPage.content} />
      </MaxWidth>

      <Surprises />
      <TrackingSDK pageData={tracking} />
    </>
  )
}
