import Title from "@/components/MyPages/Title"
import { request } from "@/lib/graphql/request"
import GetBenefitsPage from "@/lib/graphql/Query/BenefitPage.graphql"
import type { GetBenefitsPageData } from "@/types/requests/benefitPage"
import { LangParams, PageArgs } from "@/types/params"
import { serverClient } from "@/lib/trpc/server"

export default async function BenefitsPage({ params }: PageArgs<LangParams>) {
  const contentResponse = await request<GetBenefitsPageData>(GetBenefitsPage, {
    locale: params.lang,
    url: "/my-pages/benefits",
  })

  const benefitsData = await serverClient().user.get()

  if (!contentResponse.data.all_my_page?.total) {
    console.log("#### DATA ####")
    console.log(contentResponse.data)
    throw new Error("Not found")
  }

  const contentData = contentResponse.data.all_my_page.items[0]

  return (
    <main>
      <div>
        <Title>{contentData.title}</Title>
      </div>
      Benefits!
    </main>
  )
}
