import { getPayload } from 'payload'
import config from '@/payload.config'
import { FaQSection } from '@/components/pages/Home/FaqSection'
import { HeroImgOnly } from '@/components/shared/HeroImgOnly'
import { Media } from '@/payload-types'
import { Conditions } from '@/components/pages/RentalTerms/Conditions'
import { ContactSectionForm } from '@/globals/ContactForm/Component'
import { getCurrentLocale } from '@/locales/server'

export default async function RentalTermsPage() {
  const payloadConfig = await config
  const payload = await getPayload({ config: payloadConfig })

  const locale = await getCurrentLocale()
  const { hero, faq, conditions } = await payload.findGlobal({
    slug: 'rental-terms',
    depth: 1,
    locale,
  })
  return (
    <>
      {hero?.bg && <HeroImgOnly bg={hero.bg as Media} />}
      {faq && <FaQSection {...faq} />}
      {conditions && <Conditions {...conditions} />}
      <ContactSectionForm />
    </>
  )
}
