import type { GetStaticProps, InferGetStaticPropsType } from 'next'

import { getGlobalFields } from '@/lib/api/globals'
import { getFaqPage } from '@/lib/api/faq'

import FaqTemplate from '@/components/templates/Faq'

export default function Faq({ page }: InferGetStaticPropsType<typeof getStaticProps>) {
  return <FaqTemplate page={page} />
}

export const getStaticProps: GetStaticProps = async ({ preview = false }) => {
  const { globals } = await getGlobalFields(preview)
  const { page } = await getFaqPage()

  return {
    props: {
      globals,
      page,
    },
    revalidate: 60, // In seconds
  }
}
