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

import SectionContainer from "@/components/Section/Container"
import SectionHeader from "@/components/Section/Header"
import SectionLink from "@/components/Section/Link"
import Divider from "@/components/TempDesignSystem/Divider"

import Friend from "../../Overview/Friend"
import Hero from "../../Overview/Friend/Hero"
import Stats from "../../Overview/Stats"

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

import type { AccountPageComponentProps } from "@/types/components/myPages/myPage/accountPage"

export default async function PointsOverview({
  link,
  subtitle,
  title,
}: AccountPageComponentProps) {
  const user = await serverClient().user.get()
  if (!user || "error" in user) {
    return null
  }

  return (
    <SectionContainer>
      <SectionHeader link={link} preamble={subtitle} title={title} topTitle />
      <Hero color="burgundy">
        <Friend user={user} color="red" />
        <Divider className={styles.divider} color="peach" />
        <Stats user={user} />
      </Hero>
      <SectionLink link={link} variant="mobile" />
    </SectionContainer>
  )
}
