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

import Content from "@/components/MyPages/AccountPage/Content"
import Title from "@/components/TempDesignSystem/Text/Title"
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}>
      <Title>{accountPage.heading}</Title>
      {accountPage.content.length ? (
        <Content lang={params.lang} content={accountPage.content} />
      ) : (
        <p>{formatMessage({ id: "No content published" })}</p>
      )}
    </main>
  )
}
