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

import Form from "@/components/Forms/Edit/Profile"
import TrackingSDK from "@/components/TrackingSDK"

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

export default async function EditProfileSlot() {
  const caller = await serverClient()
  const accountPage = await caller.contentstack.accountPage.get()
  const user = await getProfile()

  if (!user || "error" in user) {
    return null
  }
  return (
    <>
      <div className={styles.container}>
        <Form user={user} />
        {accountPage && <TrackingSDK pageData={accountPage.tracking} />}
      </div>
    </>
  )
}
