import type { GetStaticProps, InferGetStaticPropsType } from 'next'

import { getGlobalFields } from '@/lib/api/globals'
import { getSalesRepPage } from '@/lib/api/contact'

import ContactTemplate from '@/components/templates/Contact'

export default function FindARep({ page, menu, repStates }: InferGetStaticPropsType<typeof getStaticProps>) {
  return <ContactTemplate page={page} menu={menu} repStates={repStates} />
}

export const getStaticProps: GetStaticProps = async ({ preview = false }) => {
  const { globals } = await getGlobalFields(preview)
  const { page, menu, repStates } = await getSalesRepPage()

  return {
    props: {
      globals,
      page,
      menu,
      repStates,
    },
    revalidate: 10, // In seconds
  }
}
