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

import Content from "@/components/MyPages/AccountPage/Content"
import { getIntl } from "@/i18n"

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

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

export default async function MyPages({
  params,
}: PageArgs<LangParams & { path: string[] }>) {
  const accountPage = await serverClient().contentstack.accountPage.get()
  const { formatMessage } = await getIntl()

  if (!accountPage) {
    return null
  }

  return (
    <main className={styles.blocks}>
      {accountPage.content.length ? (
        <Content lang={params.lang} content={accountPage.content} />
      ) : (
        <p>{formatMessage({ id: "No content published" })}</p>
      )}
    </main>
  )
}
