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

import SectionHeader from "@/components/SectionHeader"

import Container from "../Container"
import ClientPreviousStays from "./Client"

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

export default async function PreviousStays({
  lang,
  title,
  subtitle,
  link,
}: AccountPageComponentProps) {
  const initialPreviousStays = await serverClient().user.stays.previous()
  if (!initialPreviousStays?.data) {
    return null
  }
  return (
    <Container>
      <SectionHeader title={title} subtitle={subtitle} link={link} />
      <ClientPreviousStays
        initialPreviousStays={initialPreviousStays}
        lang={lang}
      />
    </Container>
  )
}
