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

import Content from "@/components/MyPages/AccountPage/Content"
import Sidebar from "@/components/MyPages/Sidebar"

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()

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